public async Task MoveCommand( CommandContext ctx, [Description("A channel to move to. Leave blank if you want the bot to move to the channel you're sitting in.")] [RemainingText] string channel = null) { var connection = ctx.Client.GetVoiceNext().GetConnection(ctx.Guild); if (connection?.TargetChannel == null) { await ctx.RespondAsync($"The bot is not currently in a channel."); return; } DiscordChannel ch = ResolveChannel(ctx.Guild, channel); ch ??= ctx.Member.VoiceState?.Channel; if (ch == null) { await ctx.RespondAsync("Couldn't find a channel to move to."); return; } connection.VoiceReceived -= VoiceReceiveHandler; connection.Dispose(); connection = await ch.ConnectAsync(); connection.VoiceReceived += VoiceReceiveHandler; }
public async Task Join(CommandContext ctx, DiscordChannel chn = null) { _vnext = ctx.Client.GetVoiceNext(); if (_vnext == null) { await ctx.RespondAsync(":x: VNext is not enabled or configured."); return; } VoiceNextConnection vnc = _vnext.GetConnection(ctx.Guild); if (vnc != null) { await ctx.RespondAsync("Already connected."); 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 chn.ConnectAsync(); await ctx.RespondAsync($"Connected to `{chn.Name}`"); }
public async Task StartCommand( CommandContext ctx, [Description("A channel to join. Leave blank if you want the bot to join the channel you're sitting in.")] [RemainingText] string channel = null) { var connection = ctx.Client.GetVoiceNext().GetConnection(ctx.Guild); if (connection?.TargetChannel != null) { await ctx.RespondAsync($"The bot is already in a channel `{connection.TargetChannel.Name}`."); return; } DiscordChannel ch = ResolveChannel(ctx.Guild, channel); ch ??= ctx.Member.VoiceState?.Channel; if (ch == null) { await ctx.RespondAsync("Couldn't find a channel to join."); return; } stash.StartServerSession(ctx.Guild.Id); connection = await ch.ConnectAsync(); connection.VoiceReceived += VoiceReceiveHandler; }
public async Task StartCommand(CommandContext ctx, DiscordChannel channel = null) { channel ??= ctx.Member.VoiceState?.Channel; var connection = await channel.ConnectAsync(); Directory.CreateDirectory("Output"); connection.VoiceReceived += VoiceReceiveHandler; }
public async Task CreatePlayerAsync(DiscordChannel discordChannel) { if (Connection != null) { return; } Connection = await discordChannel.ConnectAsync(); }
public async Task QuickPlayCommand(CommandContext ctx, DiscordChannel channel = null) { channel ??= ctx.Member.VoiceState?.Channel; var connection = await channel.ConnectAsync(); var transmit = connection.GetTransmitSink(); var pcm = ConvertAudioToPcm("mellan.wav"); await pcm.CopyToAsync(transmit); }
public async Task JoinCommand(CommandContext ctx, DiscordChannel channel = null) { channel ??= ctx.Member.VoiceState?.Channel; if (channel == null) { await ctx.RespondAsync("You are not in a channel >: ("); } else { await channel.ConnectAsync(); } }
private async Task JoinVCChannel(CommandContext ctx, DiscordChannel channel = null) { try { channel ??= ctx.Member.VoiceState?.Channel; if (channel == null) { return; } await channel.ConnectAsync().ConfigureAwait(false); } catch (Exception e) { return; } }
public async Task <bool> TryJoinVoiceChannel(DiscordGuild guild, DiscordMember commandAuthor, DiscordMessage commandMessage) { VoiceNextConnection vnc = _voiceNextExtension.GetConnection(guild); DiscordChannel chn = commandAuthor?.VoiceState?.Channel; if (chn == null) { await commandMessage.RespondAsync("You need to be in a voice channel!"); return(false); } if (guild.AfkChannel != null && guild.AfkChannel.Id == chn.Id) { await commandMessage.RespondAsync("You are in the AFK channel!"); return(false); } if (vnc != null) { if (vnc.TargetChannel.Id == chn.Id) { await commandMessage.RespondAsync("I am already in that channel!"); } else { await commandMessage.RespondAsync("I am already in a channel for this guild!"); } return(false); } await chn.ConnectAsync(); DiscordMember bot = await guild.GetMemberAsync(_botCoreModule.DiscordClient.CurrentUser.Id); if (!bot.VoiceState.IsServerDeafened) { await bot.ModifyAsync(member => member.Deafened = true); } return(true); }
public async Task JoinCommand(CommandContext ctx, DiscordChannel channel = null) { channel ??= ctx.Member.VoiceState?.Channel; await channel.ConnectAsync(); }