From 7de8b22e0ecae15b39507b49844dac3365a7ac3b Mon Sep 17 00:00:00 2001 From: smyalygames Date: Sun, 19 Feb 2023 21:27:08 +0000 Subject: [PATCH] feat(arabot): dealt with nv restrict roles in other commands --- src/commands/mod/restriction/restrict.ts | 1 + src/commands/roles/nvAccess.ts | 65 ------------------------ src/commands/roles/vegan.ts | 6 ++- 3 files changed, 6 insertions(+), 66 deletions(-) delete mode 100644 src/commands/roles/nvAccess.ts diff --git a/src/commands/mod/restriction/restrict.ts b/src/commands/mod/restriction/restrict.ts index cfc3915..3810e8d 100644 --- a/src/commands/mod/restriction/restrict.ts +++ b/src/commands/mod/restriction/restrict.ts @@ -214,6 +214,7 @@ export async function restrictRun( IDs.roles.vegan.vegan, IDs.roles.vegan.plus, IDs.roles.vegan.activist, + IDs.roles.vegan.nvAccess, IDs.roles.trusted, IDs.roles.nonvegan.nonvegan, IDs.roles.nonvegan.convinced, diff --git a/src/commands/roles/nvAccess.ts b/src/commands/roles/nvAccess.ts deleted file mode 100644 index 5fddacf..0000000 --- a/src/commands/roles/nvAccess.ts +++ /dev/null @@ -1,65 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0-or-later -/* - Animal Rights Advocates Discord Bot - Copyright (C) 2023 Anthony Berg - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - */ - -import { Command } from '@sapphire/framework'; -import type { Message } from 'discord.js'; -import IDs from '#utils/ids'; -import { DurationFormatter } from '@sapphire/time-utilities'; - -export class ActivistCommand extends Command { - public constructor(context: Command.Context, options: Command.Options) { - super(context, { - ...options, - name: 'nvaccess', - description: 'Gives the nvaccess role', - preconditions: ['DevCoordinatorOnly'], - }); - } - - public async messageRun(message: Message) { - const { guild } = message; - - if (guild === null) { - await message.reply('Guild is null'); - await message.react('❌'); - return; - } - await guild.members.fetch(); - - const vegan = await guild.roles.cache.get(IDs.roles.vegan.vegan); - - if (vegan === undefined) { - return; - } - - const vegans = vegan.members.map((member) => member); - const count = vegans.length; - const timeout = 1500; - - await message.reply(`Starting the process now, ETA to completion: ${new DurationFormatter().format(timeout * count)}`); - - for (let i = 0; i < count; i += 1) { - const member = vegans[i]; - setTimeout(async () => { - await member.roles.add(IDs.roles.vegan.nvAccess); - this.container.logger.debug(`NVAccess: Processed ${i + 1}/${count}`); - }, timeout * i); - } - } -} diff --git a/src/commands/roles/vegan.ts b/src/commands/roles/vegan.ts index 3d26932..a68a3c8 100644 --- a/src/commands/roles/vegan.ts +++ b/src/commands/roles/vegan.ts @@ -103,6 +103,7 @@ export class VeganCommand extends Command { await guildMember.roles.remove([ vegan, IDs.roles.vegan.activist, + IDs.roles.vegan.nvAccess, ]); await interaction.reply({ content: `Removed the ${vegan.name} role from ${user}`, @@ -113,7 +114,10 @@ export class VeganCommand extends Command { } // Add Vegan role to the user - await guildMember.roles.add(vegan); + await guildMember.roles.add([ + vegan, + IDs.roles.vegan.nvAccess, + ]); await guildMember.roles.remove([ IDs.roles.nonvegan.nonvegan, IDs.roles.nonvegan.convinced,