Skip to content

Commit

Permalink
fix(ranks): Fix fetching roles too often
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Crespi committed Mar 30, 2020
1 parent 55d0560 commit 736b31b
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/invites/services/Invites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ export class InvitesService extends IMService {
const style = settings.rankAssignmentStyle;

const allRanks = await this.client.cache.ranks.get(guild.id);
let allRoles: Role[] = [];

// Return early if we don't have any ranks so we do not
// get any permission issues for MANAGE_ROLES
Expand All @@ -246,14 +245,7 @@ export class InvitesService extends IMService {
const notReached: Role[] = [];

for (const rank of allRanks) {
let role = guild.roles.get(rank.roleId);

if (!role) {
if (!allRoles.length) {
allRoles = await guild.getRESTRoles();
}
role = allRoles.find((r) => r.id === rank.roleId);
}
const role = guild.roles.get(rank.roleId);

if (!role) {
console.log(`ROLE ${rank.roleId} FOR RANK DOES NOT EXIST IN GUILD ${rank.guildId}`);
Expand Down

0 comments on commit 736b31b

Please sign in to comment.