mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-09 23:15:41 +00:00
[ci skip] Add VpSharp.Commands example to samples
This commit is contained in:
parent
4c31eb58a9
commit
434dc204d9
@ -1,4 +1,5 @@
|
||||
using VpSharp.EventData;
|
||||
using VpSharp.Commands;
|
||||
using VpSharp.EventData;
|
||||
|
||||
namespace VpSharp.CSharp_Sample;
|
||||
|
||||
@ -17,6 +18,8 @@ internal static class Program
|
||||
};
|
||||
|
||||
s_client = new VirtualParadiseClient(configuration);
|
||||
var commands = s_client.UseCommands(new CommandsExtensionConfiguration {Prefixes = {"/"}});
|
||||
commands.RegisterCommands<SayCommand>();
|
||||
|
||||
s_client.AvatarJoined += ClientOnAvatarJoined;
|
||||
|
||||
|
13
Samples/VpSharp.CSharp_Sample/SayCommand.cs
Normal file
13
Samples/VpSharp.CSharp_Sample/SayCommand.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using VpSharp.Commands;
|
||||
using VpSharp.Commands.Attributes;
|
||||
|
||||
namespace VpSharp.CSharp_Sample;
|
||||
|
||||
public class SayCommand : CommandModule
|
||||
{
|
||||
[Command("say")]
|
||||
public async Task SayAsync(CommandContext context, [Remainder] string message)
|
||||
{
|
||||
await context.RespondAsync(message);
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VpSharp.Commands\VpSharp.Commands.csproj" />
|
||||
<ProjectReference Include="..\..\VpSharp\VpSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
Imports VpSharp.Commands
|
||||
Imports VpSharp.EventData
|
||||
|
||||
Module Program
|
||||
@ -6,7 +7,7 @@ Module Program
|
||||
Public Sub Main(args As String())
|
||||
MainAsync().GetAwaiter().GetResult()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Async Function MainAsync() As Task
|
||||
Dim configuration = new VirtualParadiseConfiguration _
|
||||
With {
|
||||
@ -17,16 +18,27 @@ Module Program
|
||||
}
|
||||
|
||||
_client = New VirtualParadiseClient(configuration)
|
||||
|
||||
Dim commands = _client.UseCommands(New CommandsExtensionConfiguration With { .Prefixes = {"/"} })
|
||||
commands.RegisterCommands(GetType(SayCommand))
|
||||
|
||||
Await _client.ConnectAsync()
|
||||
Await _client.LoginAsync()
|
||||
Await _client.EnterAsync("WORLD_NAME")
|
||||
Await _client.CurrentAvatar.TeleportAsync(Vector3d.Zero)
|
||||
|
||||
Await Task.Delay(-1)
|
||||
|
||||
Await Task.Delay(- 1)
|
||||
End Function
|
||||
|
||||
Private Async Sub ClientOnAvatarJoined(sender As Object, args As AvatarJoinedEventArgs) Handles _client.AvatarJoined
|
||||
Await _client.SendMessageAsync("Hello, " & args.Avatar.Name)
|
||||
End Sub
|
||||
|
||||
Private Async Sub OnChatMessage(sender As Object, args As MessageReceivedEventArgs) Handles _client.MessageReceived
|
||||
Dim message As String = args.Message.Content
|
||||
|
||||
If message.StartsWith("/say ") Then
|
||||
Await _client.SendMessageAsync(message.Substring(5))
|
||||
End If
|
||||
End Sub
|
||||
End Module
|
||||
|
12
Samples/VpSharp.VB_Sample/SayCommand.vb
Normal file
12
Samples/VpSharp.VB_Sample/SayCommand.vb
Normal file
@ -0,0 +1,12 @@
|
||||
Imports VpSharp.Commands
|
||||
Imports VpSharp.Commands.Attributes
|
||||
|
||||
Public Class SayCommand
|
||||
Inherits CommandModule
|
||||
|
||||
<Command("say")>
|
||||
Public Async Function SayAsync(context as CommandContext, <Remainder> message As String) As Task
|
||||
Await context.RespondAsync(message)
|
||||
End Function
|
||||
|
||||
End Class
|
@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\VpSharp.Commands\VpSharp.Commands.csproj" />
|
||||
<ProjectReference Include="..\..\VpSharp\VpSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user