From e4809ea50962f1f71c50593a76df2414f9dbbac4 Mon Sep 17 00:00:00 2001 From: Alex Gravely Date: Fri, 14 Jul 2017 00:20:20 -0400 Subject: [PATCH 1/3] Update client.cs Let's not have the client be a local variable, hm? --- docs/guides/getting_started/samples/intro/client.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/client.cs b/docs/guides/getting_started/samples/intro/client.cs index ea7c91932..a73082052 100644 --- a/docs/guides/getting_started/samples/intro/client.cs +++ b/docs/guides/getting_started/samples/intro/client.cs @@ -1,16 +1,17 @@ // Program.cs using Discord.WebSocket; // ... +private DiscordSocketClient _client; public async Task MainAsync() { - var client = new DiscordSocketClient(); + _client = new DiscordSocketClient(); - client.Log += Log; + _client.Log += Log; string token = "abcdefg..."; // Remember to keep this private! - await client.LoginAsync(TokenType.Bot, token); - await client.StartAsync(); + await _client.LoginAsync(TokenType.Bot, token); + await _client.StartAsync(); // Block this task until the program is closed. await Task.Delay(-1); -} \ No newline at end of file +} From 68d48b2a7ff7ac300763571bcaa2e540b0097825 Mon Sep 17 00:00:00 2001 From: Alex Gravely Date: Fri, 14 Jul 2017 00:25:35 -0400 Subject: [PATCH 2/3] Update complete.cs --- docs/guides/getting_started/samples/intro/complete.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/complete.cs b/docs/guides/getting_started/samples/intro/complete.cs index b59b6b4d9..a75f1d807 100644 --- a/docs/guides/getting_started/samples/intro/complete.cs +++ b/docs/guides/getting_started/samples/intro/complete.cs @@ -7,12 +7,14 @@ namespace MyBot { public class Program { + private DiscordSocketClient client; + public static void Main(string[] args) => new Program().MainAsync().GetAwaiter().GetResult(); public async Task MainAsync() { - var client = new DiscordSocketClient(); + client = new DiscordSocketClient(); client.Log += Log; client.MessageReceived += MessageReceived; @@ -39,4 +41,4 @@ namespace MyBot return Task.CompletedTask; } } -} \ No newline at end of file +} From 7ade35f549b2fda923321c449d701ec66bc9c27a Mon Sep 17 00:00:00 2001 From: Alex Gravely Date: Fri, 14 Jul 2017 09:19:44 -0400 Subject: [PATCH 3/3] Update complete.cs --- .../guides/getting_started/samples/intro/complete.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/complete.cs b/docs/guides/getting_started/samples/intro/complete.cs index a75f1d807..23b59ce6f 100644 --- a/docs/guides/getting_started/samples/intro/complete.cs +++ b/docs/guides/getting_started/samples/intro/complete.cs @@ -7,21 +7,21 @@ namespace MyBot { public class Program { - private DiscordSocketClient client; + private DiscordSocketClient _client; public static void Main(string[] args) => new Program().MainAsync().GetAwaiter().GetResult(); public async Task MainAsync() { - client = new DiscordSocketClient(); + _client = new DiscordSocketClient(); - client.Log += Log; - client.MessageReceived += MessageReceived; + _client.Log += Log; + _client.MessageReceived += MessageReceived; string token = "abcdefg..."; // Remember to keep this private! - await client.LoginAsync(TokenType.Bot, token); - await client.StartAsync(); + await _client.LoginAsync(TokenType.Bot, token); + await _client.StartAsync(); // Block this task until the program is closed. await Task.Delay(-1);