Add chat functionality (#1)

* Working chatbot

* Clean

* Working LLM chatbot

---------

Co-authored-by: Myx <info@azaaxin.com>
This commit is contained in:
2024-06-01 23:22:47 +02:00
committed by GitHub
parent 3d7655a902
commit a1d20fd732
11 changed files with 157 additions and 28 deletions

View File

@@ -19,13 +19,19 @@ public class DiscordEventListener(DiscordSocketClient client, IServiceScopeFacto
public async Task StartAsync()
{
client.SlashCommandExecuted += OnMessageReceivedAsync;
client.SlashCommandExecuted += OnSlashCommandRecievedAsync;
client.MessageReceived += OnMessageReceivedAsync;
await Task.CompletedTask;
}
private async Task OnMessageReceivedAsync(SocketSlashCommand arg)
private async Task OnMessageReceivedAsync(SocketMessage arg)
{
await Mediator.Publish(new MessageReceivedNotification(arg), _cancellationToken);
}
private async Task OnSlashCommandRecievedAsync(SocketSlashCommand arg)
{
await Mediator.Publish(new SlashCommandReceivedNotification(arg), _cancellationToken);
}
}

View File

@@ -3,7 +3,7 @@ using MediatR;
namespace Lunaris2.Notification;
public class MessageReceivedNotification(SocketSlashCommand message) : INotification
public class MessageReceivedNotification(SocketMessage message) : INotification
{
public SocketSlashCommand Message { get; } = message ?? throw new ArgumentNullException(nameof(message));
public SocketMessage Message { get; } = message ?? throw new ArgumentNullException(nameof(message));
}

View File

@@ -0,0 +1,9 @@
using Discord.WebSocket;
using MediatR;
namespace Lunaris2.Notification;
public class SlashCommandReceivedNotification(SocketSlashCommand message) : INotification
{
public SocketSlashCommand Message { get; } = message ?? throw new ArgumentNullException(nameof(message));
}