public async Task Join(CommandContext ctx, DiscordChannel chn = null) { VoiceNextExtension vnext = ctx.Client.GetVoiceNext(); if (vnext == null) { await ctx.RespondAsync("VNext is not enabled or configured."); return; } VoiceNextConnection vnc = vnext.GetConnection(ctx.Guild); if (vnc != null) { await ctx.RespondAsync("Already connected in this guild."); return; } DiscordVoiceState vstat = ctx.Member?.VoiceState; if (vstat?.Channel == null && chn == null) { await ctx.RespondAsync("You are not in a voice channel."); return; } if (chn == null) { chn = vstat.Channel; } await vnext.ConnectAsync(chn); await ctx.RespondAsync($"Connected to `{chn.Name}`"); }
public async Task Join(CommandContext ctx, DiscordChannel chn = null) { VoiceNextExtension vnext = ctx.Client.GetVoiceNext(); if (vnext == null) { await ctx.RespondAsync("Plugin não está habilitado!"); return; } var vnc = vnext.GetConnection(ctx.Guild); if (vnc != null) { await ctx.RespondAsync("Já estou conectado em um canal de voz."); return; } DiscordVoiceState stats = ctx.Member?.VoiceState; if (stats?.Channel == null && chn == null) { await ctx.RespondAsync("Você precisa entrar ou especificar um canal de voz"); return; } if (chn == null) { chn = stats.Channel; } // connect await vnext.ConnectAsync(chn); return; }