mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
* refactor: more oop with stores * forgot bulk delete * Revert "forgot bulk delete" This reverts commit 1b4fb999ee07b358ee6e1af9efb8981b84f83af1. * appease linter * missed some shh * fail
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
const DataStore = require('./DataStore');
|
|
const MessageReaction = require('../structures/MessageReaction');
|
|
|
|
/**
|
|
* Stores reactions.
|
|
* @private
|
|
* @extends {DataStore}
|
|
*/
|
|
class ReactionStore extends DataStore {
|
|
constructor(message, iterable) {
|
|
super(message.client, iterable, MessageReaction);
|
|
this.message = message;
|
|
}
|
|
|
|
add(data, cache) {
|
|
return super.add(data, cache, { id: data.emoji.id || data.emoji.name, extras: [this.message] });
|
|
}
|
|
|
|
/**
|
|
* Data that can be resolved to a MessageReaction object. This can be:
|
|
* * A MessageReaction
|
|
* * A Snowflake
|
|
* @typedef {MessageReaction|Snowflake} MessageReactionResolvable
|
|
*/
|
|
|
|
/**
|
|
* Resolves a MessageReactionResolvable to a MessageReaction object.
|
|
* @method resolve
|
|
* @memberof ReactionStore
|
|
* @instance
|
|
* @param {MessageReactionResolvable} reaction The MessageReaction to resolve
|
|
* @returns {?MessageReaction}
|
|
*/
|
|
|
|
/**
|
|
* Resolves a MessageReactionResolvable to a MessageReaction ID string.
|
|
* @method resolveID
|
|
* @memberof ReactionStore
|
|
* @instance
|
|
* @param {MessageReactionResolvable} role The role resolvable to resolve
|
|
* @returns {?Snowflake}
|
|
*/
|
|
|
|
/**
|
|
* Removes all reactions from a message.
|
|
* @returns {Promise<Message>}
|
|
*/
|
|
removeAll() {
|
|
return this.client.api.channels(this.message.channel.id).messages(this.message.id).reactions.delete()
|
|
.then(() => this.message);
|
|
}
|
|
}
|
|
|
|
module.exports = ReactionStore;
|