mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 09:14:14 +02:00
revert(arabot): undo the fixRoles command being only for giving nonvegan roles
This commit is contained in:
parent
9b3908cdc4
commit
e44c0c2037
@ -41,13 +41,13 @@ export class FixRolesOnReady extends Listener {
|
||||
// THIS SHOULD BE DISABLED BY DEFAULT
|
||||
// THIS IS ONLY USED FOR RESTORING ROLES TO THE SERVER!
|
||||
// ENABLING THIS UNINTENTIONALLY WILL CAUSE SLOWDOWNS TO THE BOT DUE TO RATE LIMITING!
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
});
|
||||
}
|
||||
|
||||
public async run(client: Client) {
|
||||
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
|
||||
@ -60,9 +60,7 @@ export class FixRolesOnReady extends Listener {
|
||||
|
||||
// Fetching the channel for the logs
|
||||
// Leave the snowflake parameter empty for no logs
|
||||
const logChannel = await client.channels
|
||||
.fetch('1329152627312824320')
|
||||
.catch(() => null);
|
||||
const logChannel = await client.channels.fetch('').catch(() => null);
|
||||
const sendLogs = logChannel !== null;
|
||||
|
||||
if (!sendLogs) {
|
||||
@ -109,10 +107,13 @@ export class FixRolesOnReady extends Listener {
|
||||
);
|
||||
|
||||
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
|
||||
// Checks if `channelLog` has been set to null
|
||||
// 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 runningTime = currentTime - startTime;
|
||||
|
||||
@ -127,14 +128,6 @@ export class FixRolesOnReady extends Listener {
|
||||
}
|
||||
|
||||
// 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
|
||||
const restricted = await checkActive(userId);
|
||||
@ -143,9 +136,10 @@ export class FixRolesOnReady extends Listener {
|
||||
restricted ||
|
||||
member.roles.cache.has(IDs.roles.restrictions.restricted1) ||
|
||||
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)
|
||||
) {
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -160,9 +154,6 @@ export class FixRolesOnReady extends Listener {
|
||||
|
||||
if (xp !== null && xp.xp > 0) {
|
||||
roles.push(IDs.roles.nonvegan.nonvegan);
|
||||
} else {
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,13 +163,12 @@ export class FixRolesOnReady extends Listener {
|
||||
}
|
||||
|
||||
// Log the completion
|
||||
count += 1;
|
||||
this.container.logger.info(
|
||||
`FixRolesOnReady: Given roles to ${count}/${totalMembers}.`,
|
||||
);
|
||||
|
||||
// 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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user