mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-13 16:10:36 +00:00
* Update readme.md Test Migrate from Victoria * Small fix --------- Co-authored-by: Myx <info@azaaxin.com>
31 lines
920 B
C#
31 lines
920 B
C#
using Discord.WebSocket;
|
|
using Lavalink4NET;
|
|
using Lavalink4NET.Players;
|
|
using MediatR;
|
|
|
|
namespace Lunaris2.Handler.MusicPlayer.PauseCommand;
|
|
|
|
public record PauseCommand(SocketSlashCommand Message) : IRequest;
|
|
|
|
public class PauseHandler(DiscordSocketClient client, IAudioService audioService) : IRequestHandler<PauseCommand>
|
|
{
|
|
public async Task Handle(PauseCommand 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 PlayerState.Paused)
|
|
{
|
|
await context.SendMessageAsync("Player is already paused.", client);
|
|
return;
|
|
}
|
|
|
|
await player.PauseAsync(cancellationToken);
|
|
await context.SendMessageAsync("Paused.", client);
|
|
}
|
|
} |