From 1af94410d785a30ddce24230ab073a6c56cd2e4d Mon Sep 17 00:00:00 2001 From: Christopher F Date: Thu, 21 Jul 2016 18:08:07 -0400 Subject: [PATCH] Port terminology + logging --- docs/guides/intro.md | 2 +- docs/guides/logging.md | 11 +++++++++++ docs/guides/samples/logging.cs | 19 +++++++++++++++++++ docs/guides/terminology.md | 20 ++++++++++++++++++++ docs/guides/toc.yml | 4 ++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 docs/guides/logging.md create mode 100644 docs/guides/samples/logging.cs create mode 100644 docs/guides/terminology.md diff --git a/docs/guides/intro.md b/docs/guides/intro.md index bb6577a3a..e9745a4d8 100644 --- a/docs/guides/intro.md +++ b/docs/guides/intro.md @@ -35,4 +35,4 @@ For more information, go to [MSDN's Async-Await section.](https://msdn.microsoft >[!NOTE] >In previous versions of Discord.Net, you had to hook into the `Ready` and `GuildAvailable` events to determine when your client was ready for use. ->In 1.0, the [ConnectAsync](xref:Discord.DiscordSocketClient.ConnectAsync) method will automatically wait for the Ready event, and for all guilds to stream. To avoid this, pass `false` into `ConnectAsync`. \ No newline at end of file +>In 1.0, the [ConnectAsync](xref:Discord.DiscordSocketClient#ConnectAsync) method will automatically wait for the Ready event, and for all guilds to stream. To avoid this, pass `false` into `ConnectAsync`. \ No newline at end of file diff --git a/docs/guides/logging.md b/docs/guides/logging.md new file mode 100644 index 000000000..315e14ebc --- /dev/null +++ b/docs/guides/logging.md @@ -0,0 +1,11 @@ +# Using the Logger + +Discord.Net will automatically output log messages through the @Discord.DiscordSocketClient#Log event. + +## Usage + +To handle Log Messages through Discord.Net's Logger, hook into the @Discord.DiscordSocketClient#Log event. + +The @Discord.LogMessage object has a custom `ToString` method attached to it, when outputting log messages, it is reccomended you use this, instead of building your own output message. + +[!code-csharp[](samples/logging.cs)] \ No newline at end of file diff --git a/docs/guides/samples/logging.cs b/docs/guides/samples/logging.cs new file mode 100644 index 000000000..564d79a8f --- /dev/null +++ b/docs/guides/samples/logging.cs @@ -0,0 +1,19 @@ +using Discord; + +public class Program +{ + // Note: This is the light client, it only supports REST calls. + private DiscordClient _client; + static void Main(string[] args) => new Program().Start().GetAwaiter().GetResult(); + + public async Task Start() + { + _client = new DiscordClient(new DiscordConfig() { + LogLevel = LogSeverity.Info + }); + + _client.Log += (message) => Console.WriteLine($"{message.ToString()}"); + + await _client.LoginAsync(TokenType.Bot, "bot token"); + } +} \ No newline at end of file diff --git a/docs/guides/terminology.md b/docs/guides/terminology.md new file mode 100644 index 000000000..fa52fb17c --- /dev/null +++ b/docs/guides/terminology.md @@ -0,0 +1,20 @@ +# Terminology + +## Preface + +Most terms for objects remain the same between 0.9 and 1.0. The major difference is that the ``Server`` is now called ``Guild``, to stay in line with Discord internally + +## Introduction to Interfaces + +Discord.Net 1.0 is built strictly around Interfaces. There are no methods that return a concrete object, only an interface. + +Many of the interfaces in Discord.Net are linked through inheritance. For example, @Discord.IChannel represents any channel in Discord. @Discord.IGuildChannel inherits from IChannel, and represents all channels belonging to a Guild. As a result, @Discord.IChannel can sometimes be cast to @Discord.IGuildChannel, and you may find yourself doing this frequently in order to properly utilize the library. + +### The Inheritance Tree + +You may want to familiarize yourself with the inheritance in Discord.Net. An inheritance tree is provided below. + +![](https://i.lithi.io/kpgd.png) +![](https://i.lithi.io/kNrr.png) +![](https://i.lithi.io/gs8d.png) +![](https://i.lithi.io/LAJr.png) \ No newline at end of file diff --git a/docs/guides/toc.yml b/docs/guides/toc.yml index 0c67f96a8..b30bca519 100644 --- a/docs/guides/toc.yml +++ b/docs/guides/toc.yml @@ -1,3 +1,7 @@ - name: Getting Started href: intro.md +- name: Terminology + href: terminology.md +- name: Logging + href: logging.md \ No newline at end of file