From c58d41b4162a9036c40c3399116ed49162fe4117 Mon Sep 17 00:00:00 2001 From: ViolentCrumble Date: Wed, 25 Nov 2015 15:31:40 +1000 Subject: [PATCH] Updated example so that it works on 0.8.1 --- docs/samples/getting_started.cs | 56 ++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/docs/samples/getting_started.cs b/docs/samples/getting_started.cs index 402db4a30..dbb4bbe76 100644 --- a/docs/samples/getting_started.cs +++ b/docs/samples/getting_started.cs @@ -1,29 +1,35 @@ class Program -{ - private static DiscordBotClient _client; - static void Main(string[] args) { - var client = new DiscordClient(); - - //Log some info to console - 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) => + private static DiscordClient _client; + + static void Main(string[] args) { - 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"); - }); + //This creates a new client, You can think of it as the bots own Discord window. + var client = new DiscordClient(); + + //Log some info to console + client.LogMessage += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}"); + + //Echo any message received, provided it didn't come from us + client.MessageReceived += async (s, e) => + { + //if I am not the author + if (!e.Message.IsAuthor) + //Send a message back to the same channel, with the same contents. + 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")); + + + }); + } } -}