Skip to content

Commit e83b0ca

Browse files
committed
Moving guild and roles out of for loop to remove redundant fetching
1 parent f3dc44d commit e83b0ca

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

events/db_ready.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ module.exports = {
1818
console.log("Performing daily check of old roles at 12:00pm");
1919

2020
const old_roles = await userDB.checkTimeAssigned();
21+
const guild = await client.guilds.fetch(CSESOC_SERVER_ID);
22+
const roles = await guild.roles.fetch();
23+
2124
for (const removed_role of old_roles) {
2225
try {
23-
const guild = await client.guilds.fetch(CSESOC_SERVER_ID);
2426
const member = await guild.members.fetch(removed_role.userid);
25-
const roles = await guild.roles.fetch();
2627
const role = roles.find((r) => r.name === removed_role.role_name);
2728

2829
if (member && role) {

0 commit comments

Comments
 (0)