mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-11 07:09:39 +00:00
* Update readme.md Test Migrate from Victoria * Small fix --------- Co-authored-by: Myx <info@azaaxin.com>
29 lines
907 B
C#
29 lines
907 B
C#
using Discord.WebSocket;
|
|
using Lavalink4NET;
|
|
using Lavalink4NET.Players;
|
|
using MediatR;
|
|
|
|
namespace Lunaris2.Handler.MusicPlayer.ResumeCommand;
|
|
|
|
public record ResumeCommand(SocketSlashCommand Message) : IRequest;
|
|
|
|
public class ResumeHandler(DiscordSocketClient client, IAudioService audioService) : IRequestHandler<ResumeCommand>
|
|
{
|
|
public async Task Handle(ResumeCommand command, CancellationToken cancellationToken)
|
|
{
|
|
var context = command.Message;
|
|
var player = await audioService.GetPlayerAsync(client, context, connectToVoiceChannel: true);
|
|
|
|
if (player is null)
|
|
return;
|
|
|
|
if (player.State is not PlayerState.Paused)
|
|
{
|
|
await context.SendMessageAsync("Player is not paused.", client);
|
|
return;
|
|
}
|
|
|
|
await player.ResumeAsync(cancellationToken);
|
|
await context.SendMessageAsync("Resumed.", client);
|
|
}
|
|
} |