feat: add AvatarJoined handler in integration test

This commit is contained in:
Oliver Booth 2024-06-18 15:43:20 +01:00
parent 9b6890b46f
commit 183261fedd
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
1 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using VpSharp; using VpSharp;
using VpSharp.Commands; using VpSharp.Commands;
using VpSharp.Entities; using VpSharp.Entities;
@ -29,6 +30,8 @@ var configuration = new VirtualParadiseConfiguration
}; };
using var client = new VirtualParadiseClient(configuration); using var client = new VirtualParadiseClient(configuration);
client.AvatarJoined.SubscribeAsync(OnAvatarJoined);
CommandsExtension commands = client.UseCommands(new CommandsExtensionConfiguration { Prefixes = ["!"] }); CommandsExtension commands = client.UseCommands(new CommandsExtensionConfiguration { Prefixes = ["!"] });
commands.RegisterCommands<TestCommands>(); commands.RegisterCommands<TestCommands>();
@ -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}"); Console.WriteLine($@"Entered {world.Name} with size {world.Size}");
await Task.Delay(-1); 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}");
}