mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-11 07:09:39 +00:00
Restructure
This commit is contained in:
15
Bot/Handler/GoodByeCommand/GoodbyeHandler.cs
Normal file
15
Bot/Handler/GoodByeCommand/GoodbyeHandler.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Discord.WebSocket;
|
||||
using MediatR;
|
||||
|
||||
namespace Lunaris2.Handler.GoodByeCommand
|
||||
{
|
||||
public record GoodbyeCommand(SocketSlashCommand Message) : IRequest;
|
||||
|
||||
public class GoodbyeHandler : IRequestHandler<GoodbyeCommand>
|
||||
{
|
||||
public async Task Handle(GoodbyeCommand message, CancellationToken cancellationToken)
|
||||
{
|
||||
await message.Message.RespondAsync($"Goodbye, {message.Message.User.Username}! :c");
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Bot/Handler/HelloCommand/HelloHandler.cs
Normal file
19
Bot/Handler/HelloCommand/HelloHandler.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Discord.WebSocket;
|
||||
using Lunaris2.SlashCommand;
|
||||
using MediatR;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Lunaris2.Handler.HelloCommand
|
||||
{
|
||||
public record HelloCommand(SocketSlashCommand Message) : IRequest;
|
||||
|
||||
public class HelloHandler : IRequestHandler<HelloCommand>
|
||||
{
|
||||
public async Task Handle(HelloCommand message, CancellationToken cancellationToken)
|
||||
{
|
||||
Console.WriteLine(JsonConvert.SerializeObject(Command.GetAllCommands()));
|
||||
|
||||
await message.Message.RespondAsync($"Hello, {message.Message.User.Username}!");
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Bot/Handler/MessageReceivedHandler.cs
Normal file
24
Bot/Handler/MessageReceivedHandler.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Lunaris2.Handler.GoodByeCommand;
|
||||
using Lunaris2.Notification;
|
||||
using Lunaris2.SlashCommand;
|
||||
using MediatR;
|
||||
|
||||
namespace Lunaris2.Handler;
|
||||
|
||||
public class MessageReceivedHandler(ISender mediator) : INotificationHandler<MessageReceivedNotification>
|
||||
{
|
||||
public async Task Handle(MessageReceivedNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
switch (notification.Message.CommandName)
|
||||
{
|
||||
case Command.Hello.Name:
|
||||
await mediator.Send(new HelloCommand.HelloCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Goodbye.Name:
|
||||
await mediator.Send(new GoodbyeCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user