revert(arabot): undo the fixRoles command being only for giving nonvegan roles

This commit is contained in:
Anthony Berg 2025-01-18 11:57:54 +01:00
parent 9b3908cdc4
commit e44c0c2037

View File

@ -41,13 +41,13 @@ export class FixRolesOnReady extends Listener {
// THIS SHOULD BE DISABLED BY DEFAULT // THIS SHOULD BE DISABLED BY DEFAULT
// THIS IS ONLY USED FOR RESTORING ROLES TO THE SERVER! // THIS IS ONLY USED FOR RESTORING ROLES TO THE SERVER!
// ENABLING THIS UNINTENTIONALLY WILL CAUSE SLOWDOWNS TO THE BOT DUE TO RATE LIMITING! // ENABLING THIS UNINTENTIONALLY WILL CAUSE SLOWDOWNS TO THE BOT DUE TO RATE LIMITING!
enabled: true, enabled: false,
}); });
} }
public async run(client: Client) { public async run(client: Client) {
this.container.logger.info( this.container.logger.info(
'FixRolesOnReady: Preparation before starting to fix the roles for nonvegans...', 'FixRolesOnReady: Preparation before starting to fix the roles for each user...',
); );
// Fetching the Guild // Fetching the Guild
@ -60,9 +60,7 @@ export class FixRolesOnReady extends Listener {
// Fetching the channel for the logs // Fetching the channel for the logs
// Leave the snowflake parameter empty for no logs // Leave the snowflake parameter empty for no logs
const logChannel = await client.channels const logChannel = await client.channels.fetch('').catch(() => null);
.fetch('1329152627312824320')
.catch(() => null);
const sendLogs = logChannel !== null; const sendLogs = logChannel !== null;
if (!sendLogs) { if (!sendLogs) {
@ -109,10 +107,13 @@ export class FixRolesOnReady extends Listener {
); );
for (const [userId, member] of members) { for (const [userId, member] of members) {
// Update the counter for the total number of users processed
count += 1;
// Send a message with an update for every 50 completions // Send a message with an update for every 50 completions
// Checks if `channelLog` has been set to null // Checks if `channelLog` has been set to null
// The RHS of the modulo should be around 100 // The RHS of the modulo should be around 100
if (sendLogs && count % 50 === 0) { if (sendLogs && count % 250 === 0) {
const currentTime = new Date().getTime(); const currentTime = new Date().getTime();
const runningTime = currentTime - startTime; const runningTime = currentTime - startTime;
@ -127,14 +128,6 @@ export class FixRolesOnReady extends Listener {
} }
// Checks if the user already has vegan or non-vegan role // Checks if the user already has vegan or non-vegan role
if (
member.roles.cache.has(IDs.roles.vegan.vegan) ||
member.roles.cache.has(IDs.roles.nonvegan.nonvegan)
) {
await this.delay(1000);
count++;
continue;
}
// Checks if the user is restricted, and skips over them if they are // Checks if the user is restricted, and skips over them if they are
const restricted = await checkActive(userId); const restricted = await checkActive(userId);
@ -143,9 +136,10 @@ export class FixRolesOnReady extends Listener {
restricted || restricted ||
member.roles.cache.has(IDs.roles.restrictions.restricted1) || member.roles.cache.has(IDs.roles.restrictions.restricted1) ||
member.roles.cache.has(IDs.roles.restrictions.restricted2) || member.roles.cache.has(IDs.roles.restrictions.restricted2) ||
member.roles.cache.has(IDs.roles.restrictions.restricted3) ||
member.roles.cache.has(IDs.roles.restrictions.restricted4) ||
member.roles.cache.has(IDs.roles.restrictions.restrictedVegan) member.roles.cache.has(IDs.roles.restrictions.restrictedVegan)
) { ) {
count++;
continue; continue;
} }
@ -160,9 +154,6 @@ export class FixRolesOnReady extends Listener {
if (xp !== null && xp.xp > 0) { if (xp !== null && xp.xp > 0) {
roles.push(IDs.roles.nonvegan.nonvegan); roles.push(IDs.roles.nonvegan.nonvegan);
} else {
count++;
continue;
} }
} }
@ -172,13 +163,12 @@ export class FixRolesOnReady extends Listener {
} }
// Log the completion // Log the completion
count += 1;
this.container.logger.info( this.container.logger.info(
`FixRolesOnReady: Given roles to ${count}/${totalMembers}.`, `FixRolesOnReady: Given roles to ${count}/${totalMembers}.`,
); );
// Add a delay so that there's around 4 users processed a second // Add a delay so that there's around 4 users processed a second
await this.delay(5000); await this.delay(1000);
} }
// Send the logs that the fix has finished. // Send the logs that the fix has finished.