mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-11 15:19:53 +00:00
33 lines
908 B
C#
33 lines
908 B
C#
using Discord.WebSocket;
|
|
using MediatR;
|
|
using Victoria.Node;
|
|
|
|
namespace Lunaris2.Handler.MusicPlayer.JoinCommand;
|
|
|
|
public record JoinCommand(SocketSlashCommand Message) : IRequest;
|
|
|
|
public class JoinHandler : IRequestHandler<JoinCommand>
|
|
{
|
|
private readonly LavaNode _lavaNode;
|
|
private readonly DiscordSocketClient _client;
|
|
|
|
public JoinHandler(LavaNode lavaNode, DiscordSocketClient client)
|
|
{
|
|
_lavaNode = lavaNode;
|
|
_client = client;
|
|
}
|
|
|
|
public async Task Handle(JoinCommand command, CancellationToken cancellationToken)
|
|
{
|
|
var context = command.Message;
|
|
|
|
await _lavaNode.EnsureConnected();
|
|
|
|
if (_lavaNode.HasPlayer(context.GetGuild(_client))) {
|
|
await context.RespondAsync("I'm already connected to a voice channel!");
|
|
return;
|
|
}
|
|
|
|
await context.JoinVoiceChannel(_lavaNode);
|
|
}
|
|
} |