Files
discord.js/src/stores/ReactionStore.js
Isabella 9eac19d9d8 refactor: more oop with stores (#2216)
* refactor: more oop with stores

* forgot bulk delete

* Revert "forgot bulk delete"

This reverts commit 1b4fb999ee07b358ee6e1af9efb8981b84f83af1.

* appease linter

* missed some


shh

* fail
2018-01-11 16:33:30 +00:00

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;