Merge pull request #13 from Mikedog87/patch-1

Updated getting_started.cs so that it works on 0.8.1
This commit is contained in:
RogueException
2015-11-25 01:39:16 -04:00

View File

@@ -1,29 +1,35 @@
class Program class Program
{
private static DiscordBotClient _client;
static void Main(string[] args)
{ {
var client = new DiscordClient(); private static DiscordClient _client;
//Log some info to console static void Main(string[] args)
client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
//Echo any message received, provided it didn't come from us
client.MessageCreated += async (s, e) =>
{ {
if (!e.Message.IsAuthor) //This creates a new client, You can think of it as the bots own Discord window.
await client.SendMessage(e.Message.ChannelId, e.Message.Text); var client = new DiscordClient();
};
//Log some info to console
//Convert our sync method to an async one and blocks this function until the client disconnects client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}");
client.Run(async () =>
{ //Echo any message received, provided it didn't come from us
//Connect to the Discord server usinotng our email and password client.MessageReceived += async (s, e) =>
await client.Connect("discordtest@email.com", "Password123"); {
//if I am not the author
//If we are not a member of any server, use our invite code if (!e.Message.IsAuthor)
if (!client.Servers.Any()) //Send a message back to the same channel, with the same contents.
await client.AcceptInvite("aaabbbcccdddeee"); await client.SendMessage(e.Channel, 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 using 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.AllServers.Any())
await client.AcceptInvite(client.CreateInvite("aaabbbcccdddeee"));
});
}
} }
}