Port terminology + logging

This commit is contained in:
Christopher F
2016-07-21 18:08:07 -04:00
parent e251582dc2
commit 1af94410d7
5 changed files with 55 additions and 1 deletions

View File

@@ -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`.
>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`.

11
docs/guides/logging.md Normal file
View File

@@ -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)]

View File

@@ -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");
}
}

View File

@@ -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)

View File

@@ -1,3 +1,7 @@
- name: Getting Started
href: intro.md
- name: Terminology
href: terminology.md
- name: Logging
href: logging.md