mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(Partials): add DMChannel/MessageReaction#fetch() and Parti… (#3261)
* add DMChannel#fetch() & Action#getChannel({recipients})
* ref for MessageReaction partial
* typings
* add PartialTypes.REACTION
* accommodate for fully removed reactions
* fix incorrect wording and typo
* typings: MessageReaction#count is nullable
* typings: mark MessageReaction#partial as readonly
Co-Authored-By: Vlad Frangu <kingdgrizzle@gmail.com>
* fix(User): fetch dm channel if cached one is partial
* docs: add missing comma
Co-Authored-By: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
@@ -9,8 +9,8 @@ discard the event. With partials, you're able to receive the event, with a Messa
|
||||
Partials are opt-in, and you can enable them in the Client options by specifying [PartialTypes](../typedef/PartialType):
|
||||
|
||||
```js
|
||||
// Accept partial messages and DM channels when emitting events
|
||||
new Client({ partials: ['MESSAGE', 'CHANNEL'] });
|
||||
// Accept partial messages, DM channels, and reactions when emitting events
|
||||
new Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
|
||||
```
|
||||
|
||||
## Usage & warnings
|
||||
@@ -45,6 +45,10 @@ client.on('messageReactionAdd', async (reaction, user) => {
|
||||
if (reaction.message.partial) await reaction.message.fetch();
|
||||
// Now the message has been cached and is fully available:
|
||||
console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`);
|
||||
// Fetches and caches the reaction itself, updating resources that were possibly defunct.
|
||||
if (reaction.partial) await reaction.fetch();
|
||||
// Now the reaction is fully available and the properties will be reflected accurately:
|
||||
console.log(`${reaction.count} user(s) have given the same reaction this message!`);
|
||||
});
|
||||
```
|
||||
|
||||
@@ -58,4 +62,4 @@ bot or any bot that relies on still receiving updates to resources you don't hav
|
||||
good example.
|
||||
|
||||
Currently, the only type of channel that can be uncached is a DM channel, there is no reason why guild channels should
|
||||
not be cached.
|
||||
not be cached.
|
||||
|
||||
Reference in New Issue
Block a user