From d05191ed051aa269bd8ae30f97ca3ecbd258e1f4 Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Tue, 30 May 2017 17:54:32 +0200 Subject: [PATCH 1/4] Added/clarified some comments in structure.cs --- .../getting_started/samples/intro/structure.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/structure.cs b/docs/guides/getting_started/samples/intro/structure.cs index 9e783bb9b..d611e1240 100644 --- a/docs/guides/getting_started/samples/intro/structure.cs +++ b/docs/guides/getting_started/samples/intro/structure.cs @@ -30,8 +30,8 @@ class Program LogLevel = LogSeverity.Info, // If you or another service needs to do anything with messages - // (eg. checking Reactions), you should probably - // set the MessageCacheSize here. + // (eg. checking Reactions, checking the content of edited/deleted messages), + // you must set the MessageCacheSize. You may adjust the number as needed. //MessageCacheSize = 50, // If your platform doesn't have native websockets, @@ -41,7 +41,7 @@ class Program }); } - // Create a named logging handler, so it can be re-used by addons + // Example of a logging handler. This can be re-used by addons // that ask for a Func. private static Task Logger(LogMessage message) { @@ -65,6 +65,11 @@ class Program } Console.WriteLine($"{DateTime.Now,-19} [{message.Severity,8}] {message.Source}: {message.Message}"); Console.ForegroundColor = cc; + + // If you get an error saying 'CompletedTask' doesn't exist, + // your project is targeting .NET 4.5.2 or lower. You'll need + // to adjust your project's target framework to 4.6 or higher + // (instructions for this are easily Googled). return Task.CompletedTask; } @@ -120,7 +125,7 @@ class Program // commands to be invoked by mentioning the bot instead. if (msg.HasCharPrefix('!', ref pos) /* || msg.HasMentionPrefix(_client.CurrentUser, ref pos) */) { - // Create a Command Context + // Create a Command Context. var context = new SocketCommandContext(_client, msg); // Execute the command. (result does not indicate a return value, From 12acfec1dbdedfa79fde4e3a5d11c26ebe35ffb0 Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Sun, 4 Jun 2017 23:44:39 +0200 Subject: [PATCH 2/4] Respond to feedback --- docs/guides/getting_started/samples/intro/structure.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guides/getting_started/samples/intro/structure.cs b/docs/guides/getting_started/samples/intro/structure.cs index d611e1240..bdbdf8fe4 100644 --- a/docs/guides/getting_started/samples/intro/structure.cs +++ b/docs/guides/getting_started/samples/intro/structure.cs @@ -70,6 +70,8 @@ class Program // your project is targeting .NET 4.5.2 or lower. You'll need // to adjust your project's target framework to 4.6 or higher // (instructions for this are easily Googled). + // If you *need* to run on .NET 4.5 for compat/other reasons, + // the alternative is to 'return Task.Delay(0);' instead. return Task.CompletedTask; } From 6cdc48bfa66bd48108e9931778ad4fbb95607ea1 Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Wed, 7 Jun 2017 04:32:59 +0200 Subject: [PATCH 3/4] Move instructions about BuildServiceProvider() up --- docs/guides/getting_started/samples/intro/structure.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/guides/getting_started/samples/intro/structure.cs b/docs/guides/getting_started/samples/intro/structure.cs index bdbdf8fe4..000ee2d02 100644 --- a/docs/guides/getting_started/samples/intro/structure.cs +++ b/docs/guides/getting_started/samples/intro/structure.cs @@ -99,16 +99,16 @@ class Program // and other dependencies that your commands might need. _map.AddSingleton(new SomeServiceClass()); - // Either search the program and add all Module classes that can be found: - await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); - // Or add Modules manually if you prefer to be a little more explicit: - await _commands.AddModuleAsync(); - // When all your required services are in the collection, build the container. // Tip: There's an overload taking in a 'validateScopes' bool to make sure // you haven't made any mistakes in your dependency graph. _services = _map.BuildServiceProvider(); + // Either search the program and add all Module classes that can be found: + await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); + // Or add Modules manually if you prefer to be a little more explicit: + await _commands.AddModuleAsync(); + // Subscribe a handler to see if a message invokes a command. _client.MessageReceived += HandleCommandAsync; } From b0a3ce5e7cd600ce32f7c8cd98e9ae59bc10e5bc Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Tue, 13 Jun 2017 10:58:06 +0200 Subject: [PATCH 4/4] Respond to feedback. --- docs/guides/getting_started/samples/intro/structure.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/guides/getting_started/samples/intro/structure.cs b/docs/guides/getting_started/samples/intro/structure.cs index 000ee2d02..706d0a38d 100644 --- a/docs/guides/getting_started/samples/intro/structure.cs +++ b/docs/guides/getting_started/samples/intro/structure.cs @@ -104,7 +104,8 @@ class Program // you haven't made any mistakes in your dependency graph. _services = _map.BuildServiceProvider(); - // Either search the program and add all Module classes that can be found: + // Either search the program and add all Module classes that can be found. + // Module classes *must* be marked 'public' or they will be ignored. await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); // Or add Modules manually if you prefer to be a little more explicit: await _commands.AddModuleAsync();