Added initial docs
This commit is contained in:
16
docs/samples/command.cs
Normal file
16
docs/samples/command.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
public enum Permissions
|
||||
{
|
||||
User,
|
||||
Moderator,
|
||||
Admin
|
||||
}
|
||||
|
||||
//Usage: say [text]
|
||||
client.CreateCommand("say")
|
||||
.ArgsEqual(1)
|
||||
.MinPermissions((int)Permissions.User)
|
||||
.Do(async e =>
|
||||
{
|
||||
string msg = Format.Normal(e.CommandText);
|
||||
await _client.SendMessage(e.Channel, msg);
|
||||
});
|
||||
20
docs/samples/command_group.cs
Normal file
20
docs/samples/command_group.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
client.CreateCommandGroup("invites", invites =>
|
||||
{
|
||||
invites.DefaultMinPermissions((int)Permissions.Admin);
|
||||
|
||||
//Usage: invites accept [inviteCode]
|
||||
invites.CreateCommand("accept")
|
||||
.ArgsEqual(1)
|
||||
.Do(async e =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await _client.AcceptInvite(e.Args[0]);
|
||||
await _client.SendMessage(e.Channel, "Invite \"" + e.Args[0] + "\" accepted.");
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
await _client.SendMessage(e.Channel, "Error: " + ex.Message);
|
||||
}
|
||||
});
|
||||
});
|
||||
0
docs/samples/console.cs
Normal file
0
docs/samples/console.cs
Normal file
26
docs/samples/getting_started.cs
Normal file
26
docs/samples/getting_started.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
class Program
|
||||
{
|
||||
private static DiscordBotClient _client;
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var client = new DiscordClient();
|
||||
|
||||
//Echo any message received, provided it didn't come from us
|
||||
client.MessageCreated += async (s, e) =>
|
||||
{
|
||||
if (!e.Message.IsAuthor)
|
||||
await client.SendMessage(e.Message.ChannelId, e.Message.Text);
|
||||
};
|
||||
|
||||
//Convert our sync method to an async one and blocks this function until the client disconnects
|
||||
client.Run(async () =>
|
||||
{
|
||||
//Connect to the Discord server usinotng our email and password
|
||||
await client.Connect("discordtest@email.com", "Password123");
|
||||
|
||||
//If we are not a member of any server, use our invite code
|
||||
if (!client.Servers.Any())
|
||||
await client.AcceptInvite("aaabbbcccdddeee");
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user