Files
Lunaris2.0/Bot/Handler/MusicPlayer/ClearQueueCommand/ClearQueueHandler.cs
2024-10-23 10:31:27 +02:00

22 lines
805 B
C#

using Discord.WebSocket;
using Lavalink4NET;
using MediatR;
namespace Lunaris2.Handler.MusicPlayer.ClearQueueCommand;
public record ClearQueueCommand(SocketSlashCommand Message) : IRequest;
public class DisconnectHandler(DiscordSocketClient client, IAudioService audioService) : IRequestHandler<ClearQueueCommand>
{
public async Task Handle(ClearQueueCommand command, CancellationToken cancellationToken)
{
var context = command.Message;
var player = await audioService.GetPlayerAsync(client, context, connectToVoiceChannel: true);
if (player is null)
return;
await player.Queue.ClearAsync(cancellationToken).ConfigureAwait(false);
await context.SendMessageAsync("Cleared queue. No songs are queued.", client).ConfigureAwait(false);
}
}