mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 01:24:14 +02:00
Merge pull request #50 from smyalygames/main
feat(docs): temporarily gave access to dev coordinators
This commit is contained in:
commit
a54eae65d5
@ -27,7 +27,7 @@ export class purgeVerifyingCommand extends Command {
|
||||
...options,
|
||||
name: 'purgeverifying',
|
||||
description: 'Purges all the users who have the "verify-as-vegan" role',
|
||||
preconditions: ['VerifierCoordinatorOnly'],
|
||||
preconditions: [['DevCoordinatorOnly', 'VerifierCoordinatorOnly']],
|
||||
});
|
||||
}
|
||||
|
||||
|
52
src/preconditions/DevCoordinatorOnly.ts
Normal file
52
src/preconditions/DevCoordinatorOnly.ts
Normal file
@ -0,0 +1,52 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
/*
|
||||
Animal Rights Advocates Discord Bot
|
||||
Copyright (C) 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
||||
import { IDs } from '../utils/ids';
|
||||
import type { GuildMember } from 'discord.js';
|
||||
|
||||
export class DevCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||
public override async messageRun(message: Message) {
|
||||
// for message command
|
||||
return this.checkDevCoordinator(message.member!);
|
||||
}
|
||||
|
||||
public override async chatInputRun(interaction: CommandInteraction) {
|
||||
// for slash command
|
||||
return this.checkDevCoordinator(interaction.member! as GuildMember);
|
||||
}
|
||||
|
||||
public override async contextMenuRun(interaction: ContextMenuInteraction) {
|
||||
// for context menu command
|
||||
return this.checkDevCoordinator(interaction.member! as GuildMember);
|
||||
}
|
||||
|
||||
private async checkDevCoordinator(user: GuildMember) {
|
||||
return user.roles.cache.has(IDs.roles.staff.devCoordinator)
|
||||
? this.ok()
|
||||
: this.error({ message: 'Only dev coordinators can run this command!' });
|
||||
}
|
||||
}
|
||||
|
||||
declare module '@sapphire/framework' {
|
||||
interface Preconditions {
|
||||
DevCoordinatorOnly: never;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user