[docs] Document TypeReaders, Events, and Joining Audio
This commit is contained in:
15
docs/guides/samples/joining_audio.cs
Normal file
15
docs/guides/samples/joining_audio.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
// Create an IAudioClient, and store it for later use
|
||||
private IAudioClient _audio;
|
||||
|
||||
// Create a Join command, that will join the parameter or the user's current voice channel
|
||||
[Command("join")]
|
||||
public async Task JoinChannel(IMessage msg,
|
||||
IVoiceChannel channel = null)
|
||||
{
|
||||
// Get the audio channel
|
||||
channel = channel ?? (msg.Author as IGuildUser)?.VoiceChannel;
|
||||
if (channel == null) { await msg.Channel.SendMessageAsync("User must be in a voice channel, or a voice channel must be passed as an argument."); return; }
|
||||
|
||||
// Get the IAudioClient by calling the JoinAsync method
|
||||
_audio = await channel.JoinAsync();
|
||||
}
|
||||
14
docs/guides/samples/typereader.cs
Normal file
14
docs/guides/samples/typereader.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
|
||||
public class BooleanTypeReader : TypeReader
|
||||
{
|
||||
public override Task<TypeReaderResult> Read(IMessage context, string input)
|
||||
{
|
||||
bool result;
|
||||
if (bool.TryParse(input, out result))
|
||||
return Task.FromResult(TypeReaderResult.FromSuccess(result));
|
||||
|
||||
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Input could not be parsed as a boolean."))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user