Skip to content

Commit

Permalink
refactor: RoleManager (#5131)
Browse files Browse the repository at this point in the history
* refactor(RoleManager): make use of `BaseManager#client`

* refactor(RoleManager): cool syntax

* refactor +1

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>

* refactor +2

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
  • Loading branch information
Ishmaam Khan and NotSugden committed Dec 26, 2020
1 parent 2c2249e commit 2a0dcc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/managers/RoleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class RoleManager extends BaseManager {
const data = await this.client.api.guilds(this.guild.id).roles.get();
const roles = new Collection();
for (const role of data) roles.set(role.id, this.add(role, cache));
return id ? roles.get(id) || null : roles;
return id ? roles.get(id) ?? null : roles;
}

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ class RoleManager extends BaseManager {
if (data.color) data.color = resolveColor(data.color);
if (data.permissions) data.permissions = Permissions.resolve(data.permissions);

return this.guild.client.api
return this.client.api
.guilds(this.guild.id)
.roles.post({ data, reason })
.then(r => {
Expand All @@ -135,7 +135,7 @@ class RoleManager extends BaseManager {
botRoleFor(user) {
const userID = this.client.users.resolveID(user);
if (!userID) return null;
return this.cache.find(role => role.tags && role.tags.botID === userID) || null;
return this.cache.find(role => role.tags?.botID === userID) ?? null;
}

/**
Expand All @@ -153,7 +153,7 @@ class RoleManager extends BaseManager {
* @readonly
*/
get premiumSubscriberRole() {
return this.cache.find(role => role.tags && role.tags.premiumSubscriberRole) || null;
return this.cache.find(role => role.tags?.premiumSubscriberRole) ?? null;
}

/**
Expand Down

0 comments on commit 2a0dcc5

Please sign in to comment.