Closed monbrey closed 3 years ago
Do you think a set of default intents would be a good idea? They could apply when a ClientOptions#ws#intents is not supplied and perhaps throw some sort of warning?
Do you think a set of default intents would be a good idea?
I can go either way on that. I think there's some value in forcing people to define the ones they need, as that's in line with why Discord is introducing them.
If we set a default, it should probably be all non-privileged intents, but we could also just advise that as an easy way to do it in the guide.
imo:
Documenting this here so people can reference this is future PRs.
With Discord providing supports for bots to subscribe to the type of events they want to receive via Intents, this can have some unintended impacts on how discord.js works.
Most noticeably, since Discord.js assumes all Guilds and GuildChannels will be cached (as per current functionality) omitting the
GUILDS
intent breaks things.Example code, with issue present:
In this example, the raw event emits a MESSAGE_CREATE with full message, author and member data.
The data includes
guild_id
andchannel_id
, which could be used to fetch a Guild and GuildChannel via the respective Managers. Howeverclient.on("message")
doesn't emit at all, not even a Partial. It relies on a channel existing in cache for anything to be emitted: see https://github.com/discordjs/discord.js/blob/36050d07f5ded196f5f6601619da2d3dc3604126/src/client/actions/MessageCreate.js#L7-L36Fixed:
Adding the
GUILDS
intent allows the bot to receive the full Guilds and Channels expected in the identify payload, and cache everything. Events will then emit as expected.To properly support a partial implementation of this where Guild and Channel could be uncached, the Message class would need to switch to the
guildID
/channelID
property approach, with getters for the object, in the same way member properties like<Guild>.ownerID
are handled.