mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-11 15:19:53 +00:00
Add Embed
This commit is contained in:
@@ -2,59 +2,58 @@ using Discord;
|
||||
using Discord.WebSocket;
|
||||
using Victoria.Node;
|
||||
|
||||
namespace Lunaris2.Handler.MusicPlayer
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static SocketGuild GetGuild(this SocketSlashCommand message, DiscordSocketClient client)
|
||||
{
|
||||
if (message.GuildId == null)
|
||||
{
|
||||
throw new Exception("Guild ID is null!");
|
||||
}
|
||||
|
||||
return client.GetGuild(message.GuildId.Value);
|
||||
}
|
||||
|
||||
public static IVoiceState GetVoiceState(this SocketSlashCommand message)
|
||||
{
|
||||
var voiceState = message.User as IVoiceState;
|
||||
|
||||
if (voiceState?.VoiceChannel == null)
|
||||
{
|
||||
throw new Exception("You must be connected to a voice channel!");
|
||||
}
|
||||
namespace Lunaris2.Handler.MusicPlayer;
|
||||
|
||||
return voiceState;
|
||||
}
|
||||
|
||||
public static async Task RespondAsync(this SocketSlashCommand message, string content)
|
||||
public static class Extensions
|
||||
{
|
||||
public static SocketGuild GetGuild(this SocketSlashCommand message, DiscordSocketClient client)
|
||||
{
|
||||
if (message.GuildId == null)
|
||||
{
|
||||
await message.RespondAsync(content, ephemeral: true);
|
||||
throw new Exception("Guild ID is null!");
|
||||
}
|
||||
|
||||
return client.GetGuild(message.GuildId.Value);
|
||||
}
|
||||
|
||||
public static async Task EnsureConnected(this LavaNode lavaNode)
|
||||
public static IVoiceState GetVoiceState(this SocketSlashCommand message)
|
||||
{
|
||||
var voiceState = message.User as IVoiceState;
|
||||
|
||||
if (voiceState?.VoiceChannel == null)
|
||||
{
|
||||
if(!lavaNode.IsConnected)
|
||||
await lavaNode.ConnectAsync();
|
||||
throw new Exception("You must be connected to a voice channel!");
|
||||
}
|
||||
|
||||
return voiceState;
|
||||
}
|
||||
|
||||
public static async Task JoinVoiceChannel(this SocketSlashCommand context, LavaNode lavaNode)
|
||||
public static async Task RespondAsync(this SocketSlashCommand message, string content)
|
||||
{
|
||||
await message.RespondAsync(content, ephemeral: true);
|
||||
}
|
||||
|
||||
public static async Task EnsureConnected(this LavaNode lavaNode)
|
||||
{
|
||||
if(!lavaNode.IsConnected)
|
||||
await lavaNode.ConnectAsync();
|
||||
}
|
||||
|
||||
public static async Task JoinVoiceChannel(this SocketSlashCommand context, LavaNode lavaNode)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
var textChannel = context.Channel as ITextChannel;
|
||||
await lavaNode.JoinAsync(context.GetVoiceState().VoiceChannel, textChannel);
|
||||
await context.RespondAsync($"Joined {context.GetVoiceState().VoiceChannel.Name}!");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
Console.WriteLine(exception);
|
||||
}
|
||||
var textChannel = context.Channel as ITextChannel;
|
||||
await lavaNode.JoinAsync(context.GetVoiceState().VoiceChannel, textChannel);
|
||||
await context.RespondAsync($"Joined {context.GetVoiceState().VoiceChannel.Name}!");
|
||||
}
|
||||
|
||||
public static string GetOptionValueByName(this SocketSlashCommand command, string optionName)
|
||||
{
|
||||
return command.Data.Options.FirstOrDefault(option => option.Name == optionName)?.Value.ToString() ?? string.Empty;
|
||||
catch (Exception exception) {
|
||||
Console.WriteLine(exception);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetOptionValueByName(this SocketSlashCommand command, string optionName)
|
||||
{
|
||||
return command.Data.Options.FirstOrDefault(option => option.Name == optionName)?.Value.ToString() ?? string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user