Browse Source

Remove saving Console.ForegroundColor to a local

pull/783/head
Joe4evr 8 years ago
parent
commit
10d0f0c802
1 changed files with 7 additions and 8 deletions
  1. +7
    -8
      docs/guides/getting_started/samples/intro/structure.cs

+ 7
- 8
docs/guides/getting_started/samples/intro/structure.cs View File

@@ -8,12 +8,6 @@ using Discord.WebSocket;

class Program
{
private readonly DiscordSocketClient _client;
// Keep the CommandService and IServiceCollection around for use with commands.
private readonly IServiceCollection _map = new ServiceCollection();
private readonly CommandService _commands = new CommandService();

// Program entry point
static void Main(string[] args)
{
@@ -22,6 +16,12 @@ class Program
new Program().MainAsync().GetAwaiter().GetResult();
}

private readonly DiscordSocketClient _client;
// Keep the CommandService and IServiceCollection around for use with commands.
private readonly IServiceCollection _map = new ServiceCollection();
private readonly CommandService _commands = new CommandService();

private Program()
{
_client = new DiscordSocketClient(new DiscordSocketConfig
@@ -48,7 +48,6 @@ class Program
// that ask for a Func<LogMessage, Task>.
private static Task Logger(LogMessage message)
{
var cc = Console.ForegroundColor;
switch (message.Severity)
{
case LogSeverity.Critical:
@@ -67,7 +66,7 @@ class Program
break;
}
Console.WriteLine($"{DateTime.Now,-19} [{message.Severity,8}] {message.Source}: {message.Message}");
Console.ForegroundColor = cc;
Console.ResetColor();
// If you get an error saying 'CompletedTask' doesn't exist,
// your project is targeting .NET 4.5.2 or lower. You'll need


Loading…
Cancel
Save