mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-11 15:19:53 +00:00
Lavalink4net (#3)
* Update readme.md Test Migrate from Victoria * Small fix --------- Co-authored-by: Myx <info@azaaxin.com>
This commit is contained in:
29
Bot/Handler/MusicPlayer/ResumeCommand/ResumeHandler.cs
Normal file
29
Bot/Handler/MusicPlayer/ResumeCommand/ResumeHandler.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user