Files
discord.js/src/stores/GuildChannelStore.js
bdistin dd085ceaee Datastore cleanup (#1892)
* Start Store cleanup

* wip store cleanup

* fix iterables initiating datastores

* handle the possibility of a datastore with no holds and no its own 'create' method

* more cleanup (instances that need more than just client/data)

* missed RoleStore extras

* not sure how eslint didn't catch that tab...

* avoid re-getting the channel we already have...

* cleanup resolvers and refactor them into DataStores

* ^

* and remove

* fix some bugs

* fix lint

* fix documentation maybe?

* formatting

* fix presences

* really fix presences this time

* bad fix was bad... let;s see how bad this one is..

* forgot to save a file

* make presence resolving take userresolveables too

* fix tabs in jsdocs

* fix bad fix from last night that caused issues, with better fix...

* oops
2017-09-08 23:06:10 +02:00

48 lines
1.2 KiB
JavaScript

const DataStore = require('./DataStore');
const Channel = require('../structures/Channel');
const GuildChannel = require('../structures/GuildChannel');
/**
* Stores guild channels.
* @private
* @extends {DataStore}
*/
class GuildChannelStore extends DataStore {
constructor(guild, iterable) {
super(guild.client, iterable, GuildChannel);
this.guild = guild;
}
create(data) {
const existing = this.get(data.id);
if (existing) return existing;
return Channel.create(this.client, data, this.guild);
}
/**
* Data that can be resolved to give a Channel object. This can be:
* * A GuildChannel object
* * A Snowflake
* @typedef {Channel|Snowflake} GuildChannelResolvable
*/
/**
* Resolves a GuildChannelResolvable to a Channel object.
* @method resolve
* @memberof GuildChannelStore
* @param {GuildChannelResolvable} channel The GuildChannel resolvable to resolve
* @returns {?Channel}
*/
/**
* Resolves a GuildChannelResolvable to a channel ID string.
* @method resolveID
* @memberof GuildChannelStore
* @param {GuildChannelResolvable} channel The GuildChannel resolvable to resolve
* @returns {?string}
*/
}
module.exports = GuildChannelStore;