Browse Source

Port terminology + logging

tags/1.0-rc
Christopher F 9 years ago
parent
commit
1af94410d7
5 changed files with 55 additions and 1 deletions
  1. +1
    -1
      docs/guides/intro.md
  2. +11
    -0
      docs/guides/logging.md
  3. +19
    -0
      docs/guides/samples/logging.cs
  4. +20
    -0
      docs/guides/terminology.md
  5. +4
    -0
      docs/guides/toc.yml

+ 1
- 1
docs/guides/intro.md 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
- 0
docs/guides/logging.md 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)]

+ 19
- 0
docs/guides/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");
}
}

+ 20
- 0
docs/guides/terminology.md 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)

+ 4
- 0
docs/guides/toc.yml View File

@@ -1,3 +1,7 @@

- name: Getting Started
href: intro.md
- name: Terminology
href: terminology.md
- name: Logging
href: logging.md

Loading…
Cancel
Save