diff --git a/src/stores/ChannelStore.js b/src/stores/ChannelStore.js index 64c482cb3..d0e1caa77 100644 --- a/src/stores/ChannelStore.js +++ b/src/stores/ChannelStore.js @@ -78,25 +78,6 @@ class ChannelStore extends DataStore { super.remove(id); } - /** - * Obtains a channel from Discord, or the channel cache if it's already available. - * @param {Snowflake} id ID of the channel - * @param {boolean} [cache=true] Whether to cache the new channel object if it isn't already - * @returns {Promise} - * @example - * // Fetch a channel by its id - * client.channels.fetch('222109930545610754') - * .then(channel => console.log(channel.name)) - * .catch(console.error); - */ - async fetch(id, cache = true) { - const existing = this.get(id); - if (existing && !existing.partial) return existing; - - const data = await this.client.api.channels(id).get(); - return this.add(data, null, cache); - } - /** * Data that can be resolved to give a Channel object. This can be: * * A Channel object @@ -121,6 +102,25 @@ class ChannelStore extends DataStore { * @param {ChannelResolvable} channel The channel resolvable to resolve * @returns {?Snowflake} */ + + /** + * Obtains a channel from Discord, or the channel cache if it's already available. + * @param {Snowflake} id ID of the channel + * @param {boolean} [cache=true] Whether to cache the new channel object if it isn't already + * @returns {Promise} + * @example + * // Fetch a channel by its id + * client.channels.fetch('222109930545610754') + * .then(channel => console.log(channel.name)) + * .catch(console.error); + */ + async fetch(id, cache = true) { + const existing = this.get(id); + if (existing && !existing.partial) return existing; + + const data = await this.client.api.channels(id).get(); + return this.add(data, null, cache); + } } module.exports = ChannelStore; diff --git a/src/stores/GuildChannelStore.js b/src/stores/GuildChannelStore.js index fc150f17b..55b9ebb0c 100644 --- a/src/stores/GuildChannelStore.js +++ b/src/stores/GuildChannelStore.js @@ -22,6 +22,31 @@ class GuildChannelStore extends DataStore { return channel; } + /** + * Data that can be resolved to give a Guild Channel object. This can be: + * * A GuildChannel object + * * A Snowflake + * @typedef {GuildChannel|Snowflake} GuildChannelResolvable + */ + + /** + * Resolves a GuildChannelResolvable to a Channel object. + * @method resolve + * @memberof GuildChannelStore + * @instance + * @param {GuildChannelResolvable} channel The GuildChannel resolvable to resolve + * @returns {?Channel} + */ + + /** + * Resolves a GuildChannelResolvable to a channel ID string. + * @method resolveID + * @memberof GuildChannelStore + * @instance + * @param {GuildChannelResolvable} channel The GuildChannel resolvable to resolve + * @returns {?Snowflake} + */ + /** * Creates a new channel in the guild. * @param {string} name The name of the new channel @@ -90,31 +115,6 @@ class GuildChannelStore extends DataStore { }); return this.client.actions.ChannelCreate.handle(data).channel; } - - /** - * Data that can be resolved to give a Guild Channel object. This can be: - * * A GuildChannel object - * * A Snowflake - * @typedef {GuildChannel|Snowflake} GuildChannelResolvable - */ - - /** - * Resolves a GuildChannelResolvable to a Channel object. - * @method resolve - * @memberof GuildChannelStore - * @instance - * @param {GuildChannelResolvable} channel The GuildChannel resolvable to resolve - * @returns {?Channel} - */ - - /** - * Resolves a GuildChannelResolvable to a channel ID string. - * @method resolveID - * @memberof GuildChannelStore - * @instance - * @param {GuildChannelResolvable} channel The GuildChannel resolvable to resolve - * @returns {?Snowflake} - */ } module.exports = GuildChannelStore; diff --git a/src/stores/MessageStore.js b/src/stores/MessageStore.js index e179daa21..59b224f72 100644 --- a/src/stores/MessageStore.js +++ b/src/stores/MessageStore.js @@ -82,31 +82,6 @@ class MessageStore extends DataStore { }); } - /** - * Deletes a message, even if it's not cached. - * @param {MessageResolvable} message The message to delete - * @param {string} [reason] Reason for deleting this message, if it does not belong to the client user - */ - async remove(message, reason) { - message = this.resolveID(message); - if (message) await this.client.api.channels(this.channel.id).messages(message).delete({ reason }); - } - - async _fetchId(messageID, cache) { - const existing = this.get(messageID); - if (existing && !existing.partial) return existing; - const data = await this.client.api.channels[this.channel.id].messages[messageID].get(); - return this.add(data, cache); - } - - async _fetchMany(options = {}, cache) { - const data = await this.client.api.channels[this.channel.id].messages.get({ query: options }); - const messages = new Collection(); - for (const message of data) messages.set(message.id, this.add(message, cache)); - return messages; - } - - /** * Data that can be resolved to a Message object. This can be: * * A Message @@ -131,6 +106,30 @@ class MessageStore extends DataStore { * @param {MessageResolvable} message The message resolvable to resolve * @returns {?Snowflake} */ + + /** + * Deletes a message, even if it's not cached. + * @param {MessageResolvable} message The message to delete + * @param {string} [reason] Reason for deleting this message, if it does not belong to the client user + */ + async remove(message, reason) { + message = this.resolveID(message); + if (message) await this.client.api.channels(this.channel.id).messages(message).delete({ reason }); + } + + async _fetchId(messageID, cache) { + const existing = this.get(messageID); + if (existing && !existing.partial) return existing; + const data = await this.client.api.channels[this.channel.id].messages[messageID].get(); + return this.add(data, cache); + } + + async _fetchMany(options = {}, cache) { + const data = await this.client.api.channels[this.channel.id].messages.get({ query: options }); + const messages = new Collection(); + for (const message of data) messages.set(message.id, this.add(message, cache)); + return messages; + } } module.exports = MessageStore;