mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
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
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const DataStore = require('./DataStore');
|
||||
const Role = require('../structures/Role');
|
||||
|
||||
/**
|
||||
* Stores roles.
|
||||
* @private
|
||||
@@ -7,19 +8,36 @@ const Role = require('../structures/Role');
|
||||
*/
|
||||
class RoleStore extends DataStore {
|
||||
constructor(guild, iterable) {
|
||||
super(guild.client, iterable);
|
||||
super(guild.client, iterable, Role);
|
||||
this.guild = guild;
|
||||
}
|
||||
|
||||
create(data) {
|
||||
const existing = this.get(data.id);
|
||||
if (existing) return existing;
|
||||
|
||||
const role = new Role(this.guild, data);
|
||||
this.set(role.id, role);
|
||||
|
||||
return role;
|
||||
create(data, cache) {
|
||||
return super.create(data, cache, { extras: [this.guild] });
|
||||
}
|
||||
|
||||
/**
|
||||
* Data that can be resolved to a Role object. This can be:
|
||||
* * A Role
|
||||
* * A Snowflake
|
||||
* @typedef {Role|Snowflake} RoleResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a RoleResolvable to a Role object.
|
||||
* @method resolve
|
||||
* @memberof RoleStore
|
||||
* @param {RoleResolvable} role The role resolvable to resolve
|
||||
* @returns {?Role}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolves a RoleResolvable to a role ID string.
|
||||
* @method resolveID
|
||||
* @memberof RoleStore
|
||||
* @param {RoleResolvable} role The role resolvable to resolve
|
||||
* @returns {?string}
|
||||
*/
|
||||
}
|
||||
|
||||
module.exports = RoleStore;
|
||||
|
||||
Reference in New Issue
Block a user