From 183261fedd7188e2dd9978e4589bd893c459427c Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 18 Jun 2024 15:43:20 +0100 Subject: [PATCH] feat: add AvatarJoined handler in integration test --- VpSharp.IntegrationTests/src/Program.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/VpSharp.IntegrationTests/src/Program.cs b/VpSharp.IntegrationTests/src/Program.cs index a7a9d7b..a81226a 100644 --- a/VpSharp.IntegrationTests/src/Program.cs +++ b/VpSharp.IntegrationTests/src/Program.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using VpSharp; using VpSharp.Commands; using VpSharp.Entities; @@ -29,6 +30,8 @@ var configuration = new VirtualParadiseConfiguration }; using var client = new VirtualParadiseClient(configuration); +client.AvatarJoined.SubscribeAsync(OnAvatarJoined); + CommandsExtension commands = client.UseCommands(new CommandsExtensionConfiguration { Prefixes = ["!"] }); commands.RegisterCommands(); @@ -48,3 +51,11 @@ Console.WriteLine($@"My name is {avatar.Name} and I am at {avatar.Location}"); Console.WriteLine($@"Entered {world.Name} with size {world.Size}"); await Task.Delay(-1); +return; + +[SuppressMessage("ReSharper", "AccessToDisposedClosure")] +async Task OnAvatarJoined(VirtualParadiseAvatar av) +{ + var user = await client.GetUserAsync(av.UserId); + await client.SendMessageAsync($"Hello, {av.Name}. Your user is {user.Name} with ID {user.Id}"); +}