Skip to content

Commit

Permalink
feat: add automated checkRoles
Browse files Browse the repository at this point in the history
  • Loading branch information
tippfehlr committed Apr 20, 2024
1 parent 077edc3 commit 07c4846
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/modules/bot.ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { i18n, log } from './messages';
import CommandHandler from './commandHandler';
import { configureInfluxDB } from './metrics';
import { client } from './bot';
import { checkRoles } from './commands/checkRoles';

export let commandHandler: CommandHandler;

Expand Down Expand Up @@ -69,5 +70,17 @@ export function initClientReady() {
log.info(
`The bot is currently on ${client.guilds.cache.size} guilds with ${await getUserCount()} users and manages ${await getRolesCount()} roles`,
);
checkRolesAllGuilds();
setInterval(checkRolesAllGuilds, 20 * 60 * 60 * 1000);
});
}

const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));

async function checkRolesAllGuilds() {
await client.guilds.fetch();
for (const [, guild] of client.guilds.cache) {
await delay(10 * 1000);
await checkRoles({ guild });
}
}

0 comments on commit 07c4846

Please sign in to comment.