Intents
Intents were added to Discord to help the service not have to push so many events to the bots that were not using them. If you are going to be needing to subscribe to any type of event, they are going to have to be defined BOTH within the Discord Application under the Bot Page on Discords Site and also within the DiscordConfiguration.
Discord Application
On the Discord Application under the Bot Page you will have to specify if your bot requires Privileged Intents. We recommend having these all enabled at first to ensure the most stability when building your first bot, otherwise you may run into issues when retrieving entities from the library's cache.
Warning
These privileged intents may not be available for you to toggle on immediately.
Due to their nature of sensitive data, Discord requires you to go through a verification process once your bot is in a certain amount of servers. Please read this blog post for more information and how to apply.
Discord Configuration
Within your setup code you will have to specify all the intents you will need. Here is a list of all the Intents DSharpPlus Supports. Like above however, we recommend having all intents enabled during initial development, so you should specify All in your configuration which will include the privleged intents you enabled in your application:
DiscordClientBuilder builder = DiscordClientBuilder.CreateDefault(token, DiscordIntents.All);
When you become more advanced, you should try experimenting with turning off intents you do not need in order to save resources. In your DiscordClientBuilder you can specify one or many.
Here is an example of just specifying one:
DiscordClientBuilder builder = DiscordClientBuilder.CreateDefault(token, DiscordIntents.GuildMessages);
Here is an example of specifying many:
DiscordClientBuilder builder = DiscordClientBuilder.CreateDefault
(
token,
DiscordIntents.DirectMessageReactions
| DiscordIntents.DirectMessages
| DiscordIntents.GuildBans
| DiscordIntents.GuildEmojis
| DiscordIntents.GuildInvites
| DiscordIntents.GuildMembers
| DiscordIntents.GuildMessages
| DiscordIntents.Guilds
| DiscordIntents.GuildVoiceStates
| DiscordIntents.GuildWebhooks
};
Please Note, if you specify a privileged intent that you have not signed up for on the Discord Application page, an error will be thrown on the connection.