From 929077d71741d81337259944ea32674977501223 Mon Sep 17 00:00:00 2001 From: Still Hsu <341464@gmail.com> Date: Tue, 1 May 2018 05:36:06 +0800 Subject: [PATCH] Read token from Environment Variable instead of hardcode --- docs/guides/commands/samples/require_owner.cs | 3 ++- docs/guides/commands/samples/typereader.cs | 3 ++- docs/guides/concepts/samples/connections.cs | 2 +- docs/guides/concepts/samples/events.cs | 2 +- docs/guides/concepts/samples/logging.cs | 2 +- docs/guides/getting_started/samples/first-bot/client.cs | 5 ++--- docs/guides/getting_started/samples/first-bot/complete.cs | 3 +-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/guides/commands/samples/require_owner.cs b/docs/guides/commands/samples/require_owner.cs index aa218539e..a4e95cfcb 100644 --- a/docs/guides/commands/samples/require_owner.cs +++ b/docs/guides/commands/samples/require_owner.cs @@ -1,4 +1,5 @@ -// (Note: This precondition is obsolete, it is recommended to use the RequireOwnerAttribute that is bundled with Discord.Commands) +// (Note: This precondition is obsolete, it is recommended to use the +// RequireOwnerAttribute that is bundled with Discord.Commands) using Discord.Commands; using Discord.WebSocket; diff --git a/docs/guides/commands/samples/typereader.cs b/docs/guides/commands/samples/typereader.cs index b792a9269..a2a4627d2 100644 --- a/docs/guides/commands/samples/typereader.cs +++ b/docs/guides/commands/samples/typereader.cs @@ -1,4 +1,5 @@ -// Note: This example is obsolete, a boolean type reader is bundled with Discord.Commands +// Note: This example is obsolete, a boolean type reader is bundled +// with Discord.Commands using Discord; using Discord.Commands; diff --git a/docs/guides/concepts/samples/connections.cs b/docs/guides/concepts/samples/connections.cs index f96251a39..b610da524 100644 --- a/docs/guides/concepts/samples/connections.cs +++ b/docs/guides/concepts/samples/connections.cs @@ -10,7 +10,7 @@ public class Program { _client = new DiscordSocketClient(); - await _client.LoginAsync(TokenType.Bot, "bot token"); + await _client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("DiscordToken")); await _client.StartAsync(); Console.WriteLine("Press any key to exit..."); diff --git a/docs/guides/concepts/samples/events.cs b/docs/guides/concepts/samples/events.cs index cf0492cb5..dce625b33 100644 --- a/docs/guides/concepts/samples/events.cs +++ b/docs/guides/concepts/samples/events.cs @@ -14,7 +14,7 @@ public class Program var _config = new DiscordSocketConfig { MessageCacheSize = 100 }; _client = new DiscordSocketClient(_config); - await _client.LoginAsync(TokenType.Bot, "bot token"); + await _client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("DiscordToken")); await _client.StartAsync(); _client.MessageUpdated += MessageUpdated; diff --git a/docs/guides/concepts/samples/logging.cs b/docs/guides/concepts/samples/logging.cs index a2ddf7b90..2419452f0 100644 --- a/docs/guides/concepts/samples/logging.cs +++ b/docs/guides/concepts/samples/logging.cs @@ -15,7 +15,7 @@ public class Program _client.Log += Log; - await _client.LoginAsync(TokenType.Bot, "bot token"); + await _client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("DiscordToken")); await _client.StartAsync(); await Task.Delay(-1); diff --git a/docs/guides/getting_started/samples/first-bot/client.cs b/docs/guides/getting_started/samples/first-bot/client.cs index b3bf39865..6ff75b8a3 100644 --- a/docs/guides/getting_started/samples/first-bot/client.cs +++ b/docs/guides/getting_started/samples/first-bot/client.cs @@ -6,10 +6,9 @@ public async Task MainAsync() _client.Log += Log; - // Remember to keep this private or to read this + // Remember to keep token private or to read it // from an external source! - string token = "abcdefg..."; - await _client.LoginAsync(TokenType.Bot, token); + await _client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("DiscordToken")); await _client.StartAsync(); // Block this task until the program is closed. diff --git a/docs/guides/getting_started/samples/first-bot/complete.cs b/docs/guides/getting_started/samples/first-bot/complete.cs index 965b57a5e..8c3903d41 100644 --- a/docs/guides/getting_started/samples/first-bot/complete.cs +++ b/docs/guides/getting_started/samples/first-bot/complete.cs @@ -14,8 +14,7 @@ public class Program // Remember to keep this private or to read this // from an external source! - string token = "abcdefg..."; - await _client.LoginAsync(TokenType.Bot, token); + await _client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("DiscordToken")); await _client.StartAsync(); // Block this task until the program is closed.