You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

joining_audio.cs 663 B

8 years ago
8 years ago
1234567891011
  1. // The command's Run Mode MUST be set to RunMode.Async, otherwise, being connected to a voice channel will block the gateway thread.
  2. [Command("join", RunMode = RunMode.Async)]
  3. public async Task JoinChannel(IVoiceChannel channel = null)
  4. {
  5. // Get the audio channel
  6. channel = channel ?? (Context.User as IGuildUser)?.VoiceChannel;
  7. if (channel == null) { await Context.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be passed as an argument."); return; }
  8. // For the next step with transmitting audio, you would want to pass this Audio Client in to a service.
  9. var audioClient = await channel.ConnectAsync();
  10. }