Browse Source

Update FAQ & Migration guide to include Intents (#1987)

* Update client-basics.md

* Update v2_to_v3_guide.md
tags/3.1.0
Armano den Boef GitHub 3 years ago
parent
commit
e779e97fa5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 104 additions and 0 deletions
  1. +52
    -0
      docs/faq/basics/client-basics.md
  2. +52
    -0
      docs/guides/v2_v3_guide/v2_to_v3_guide.md

+ 52
- 0
docs/faq/basics/client-basics.md View File

@@ -9,6 +9,58 @@ In the following section, you will find commonly asked questions and
answers about common issues that you may face when utilizing the answers about common issues that you may face when utilizing the
various clients offered by the library. various clients offered by the library.


## I keep having trouble with intents!

As Discord.NET has upgraded from Discord API v6 to API v9,
`GatewayIntents` must now be specified in the socket config, as well as on the [developer portal].

```cs

// Where ever you declared your websocket client.
DiscordSocketClient _client;

...

var config = new DiscordSocketConfig()
{
.. // Other config options can be presented here.
GatewayIntents = GatewayIntents.All
}

_client = new DiscordSocketClient(config);

```
### Common intents:

- AllUnprivileged: This is a group of most common intents, that do NOT require any [developer portal] intents to be enabled.
This includes intents that receive messages such as: `GatewayIntents.GuildMessages, GatewayIntents.DirectMessages`
- GuildMembers: An intent disabled by default, as you need to enable it in the [developer portal].
- GuildPresences: Also disabled by default, this intent together with `GuildMembers` are the only intents not included in `AllUnprivileged`.
- All: All intents, it is ill adviced to use this without care, as it *can* cause a memory leak from presence.
The library will give responsive warnings if you specify unnecessary intents.


> [!NOTE]
> All gateway intents, their Discord API counterpart and their enum value are listed
> [HERE](xref:Discord.GatewayIntents)

### Stacking intents:

It is common that you require several intents together.
The example below shows how this can be done.

```cs

GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildMembers | ..

```

> [!NOTE]
> Further documentation on the ` | ` operator can be found
> [HERE](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators)

[developer portal]: https://discord.com/developers/

## My client keeps returning 401 upon logging in! ## My client keeps returning 401 upon logging in!


> [!WARNING] > [!WARNING]


+ 52
- 0
docs/guides/v2_v3_guide/v2_to_v3_guide.md View File

@@ -10,6 +10,58 @@ and more flexible library than any previous version.


Below are the most notable breaking changes that you would need to update your code to work with V3. Below are the most notable breaking changes that you would need to update your code to work with V3.


### GatewayIntents

As Discord.NET has upgraded from Discord API v6 to API v9,
`GatewayIntents` must now be specified in the socket config, as well as on the [developer portal].

```cs

// Where ever you declared your websocket client.
DiscordSocketClient _client;

...

var config = new DiscordSocketConfig()
{
.. // Other config options can be presented here.
GatewayIntents = GatewayIntents.All
}

_client = new DiscordSocketClient(config);

```
#### Common intents:

- AllUnprivileged: This is a group of most common intents, that do NOT require any [developer portal] intents to be enabled.
This includes intents that receive messages such as: `GatewayIntents.GuildMessages, GatewayIntents.DirectMessages`
- GuildMembers: An intent disabled by default, as you need to enable it in the [developer portal].
- GuildPresences: Also disabled by default, this intent together with `GuildMembers` are the only intents not included in `AllUnprivileged`.
- All: All intents, it is ill adviced to use this without care, as it *can* cause a memory leak from presence.
The library will give responsive warnings if you specify unnecessary intents.


> [!NOTE]
> All gateway intents, their Discord API counterpart and their enum value are listed
> [HERE](xref:Discord.GatewayIntents)

#### Stacking intents:

It is common that you require several intents together.
The example below shows how this can be done.

```cs

GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.GuildMembers | ..

```

> [!NOTE]
> Further documentation on the ` | ` operator can be found
> [HERE](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/bitwise-and-shift-operators)

[developer portal]: https://discord.com/developers/

### ReactionAdded Event ### ReactionAdded Event


The reaction added event has been changed to have both parameters cacheable. The reaction added event has been changed to have both parameters cacheable.


Loading…
Cancel
Save