Small fix

This commit is contained in:
Myx
2024-08-11 16:03:42 +02:00
parent 05b7324ecc
commit 34375f52bd
4 changed files with 14 additions and 14 deletions

View File

@@ -90,7 +90,5 @@ public class PlayHandler : IRequestHandler<PlayCommand>
await context.SendMessageAsync($"Couldn't read song information", _client); await context.SendMessageAsync($"Couldn't read song information", _client);
} }
} }
_audioService.TrackStarted += OnTrackStarted;
} }
} }

View File

@@ -1,6 +1,7 @@
using Lunaris2.Handler.GoodByeCommand; using Lunaris2.Handler.MusicPlayer.DisconnectCommand;
using Lunaris2.Handler.MusicPlayer.JoinCommand; using Lunaris2.Handler.MusicPlayer.PauseCommand;
using Lunaris2.Handler.MusicPlayer.PlayCommand; using Lunaris2.Handler.MusicPlayer.PlayCommand;
using Lunaris2.Handler.MusicPlayer.ResumeCommand;
using Lunaris2.Handler.MusicPlayer.SkipCommand; using Lunaris2.Handler.MusicPlayer.SkipCommand;
using Lunaris2.Notification; using Lunaris2.Notification;
using Lunaris2.SlashCommand; using Lunaris2.SlashCommand;
@@ -12,16 +13,18 @@ public class SlashCommandReceivedHandler(ISender mediator) : INotificationHandle
{ {
public async Task Handle(SlashCommandReceivedNotification notification, CancellationToken cancellationToken) public async Task Handle(SlashCommandReceivedNotification notification, CancellationToken cancellationToken)
{ {
await notification.Message.DeferAsync();
switch (notification.Message.CommandName) switch (notification.Message.CommandName)
{ {
case Command.Hello.Name: case Command.Resume.Name:
await mediator.Send(new HelloCommand.HelloCommand(notification.Message), cancellationToken); await mediator.Send(new ResumeCommand(notification.Message), cancellationToken);
break; break;
case Command.Goodbye.Name: case Command.Pause.Name:
await mediator.Send(new GoodbyeCommand(notification.Message), cancellationToken); await mediator.Send(new PauseCommand(notification.Message), cancellationToken);
break; break;
case Command.Join.Name: case Command.Disconnect.Name:
await mediator.Send(new JoinCommand(notification.Message), cancellationToken); await mediator.Send(new DisconnectCommand(notification.Message), cancellationToken);
break; break;
case Command.Play.Name: case Command.Play.Name:
await mediator.Send(new PlayCommand(notification.Message), cancellationToken); await mediator.Send(new PlayCommand(notification.Message), cancellationToken);

View File

@@ -25,7 +25,7 @@ public class DiscordEventListener(DiscordSocketClient client, IServiceScopeFacto
await Task.CompletedTask; await Task.CompletedTask;
} }
private async Task OnMessageReceivedAsync(SocketMessage arg) private Task OnMessageReceivedAsync(SocketMessage arg)
{ {
_ = Task.Run(() => Mediator.Publish(new MessageReceivedNotification(arg), _cancellationToken), _cancellationToken); _ = Task.Run(() => Mediator.Publish(new MessageReceivedNotification(arg), _cancellationToken), _cancellationToken);
return Task.CompletedTask; return Task.CompletedTask;

View File

@@ -10,6 +10,7 @@ using Lunaris2.SlashCommand;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Victoria.Node;
namespace Lunaris2; namespace Lunaris2;
@@ -41,8 +42,7 @@ public class Program
services services
.AddSingleton(client) .AddSingleton(client)
.AddSingleton(commands) .AddMediatR(mediatRServiceConfiguration => mediatRServiceConfiguration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()))
.AddMediatR(configuration => configuration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()))
.AddSingleton<DiscordEventListener>() .AddSingleton<DiscordEventListener>()
.AddSingleton(service => new InteractionService(service.GetRequiredService<DiscordSocketClient>())) .AddSingleton(service => new InteractionService(service.GetRequiredService<DiscordSocketClient>()))
.AddLavalink() .AddLavalink()
@@ -63,7 +63,6 @@ public class Program
client.Ready += () => Client_Ready(client); client.Ready += () => Client_Ready(client);
client.Log += Log; client.Log += Log;
client client
.LoginAsync(TokenType.Bot, configuration["Token"]) .LoginAsync(TokenType.Bot, configuration["Token"])
.GetAwaiter() .GetAwaiter()