mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 17:04:15 +02:00
refactor(arabot): change outreach command for outreach leader only
This commit is contained in:
parent
a9039572d1
commit
c82d256be4
@ -66,7 +66,6 @@ export class OutreachCommand extends Subcommand {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
preconditions: ['ModOnly'],
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,13 +199,13 @@ export class OutreachCommand extends Subcommand {
|
|||||||
|
|
||||||
if (mod === undefined) {
|
if (mod === undefined) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'Mod was not found!',
|
content: 'Outreach Leader was not found!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mod.roles.cache.has(IDs.roles.staff.outreachCoordinator)) {
|
if (!mod.roles.cache.has(IDs.roles.staff.outreachLeader)) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'You need to be an Outreach Coordinator to run this command!',
|
content: 'You need to be an Outreach Coordinator to run this command!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
@ -254,9 +253,9 @@ export class OutreachCommand extends Subcommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mod.roles.cache.has(IDs.roles.staff.outreachCoordinator)) {
|
if (!mod.roles.cache.has(IDs.roles.staff.outreachLeader)) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'You need to be an Outreach Coordinator to run this command!',
|
content: 'You need to be an Outreach Leader to run this command!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -442,7 +441,7 @@ export class OutreachCommand extends Subcommand {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
leader.id !== stat.stat.leaderId &&
|
leader.id !== stat.stat.leaderId &&
|
||||||
!leaderMember.roles.cache.has(IDs.roles.staff.outreachCoordinator)
|
!leaderMember.roles.cache.has(IDs.roles.staff.outreachLeader)
|
||||||
) {
|
) {
|
||||||
await interaction.editReply({
|
await interaction.editReply({
|
||||||
content: `You are not the leader for ${group}`,
|
content: `You are not the leader for ${group}`,
|
||||||
|
58
src/preconditions/OutreachLeaderOnly.ts
Normal file
58
src/preconditions/OutreachLeaderOnly.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// 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,
|
||||||
|
ContextMenuCommandInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
|
import IDs from '#utils/ids';
|
||||||
|
|
||||||
|
export class OutreachLeaderOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
|
public override async messageRun(message: Message) {
|
||||||
|
// for message command
|
||||||
|
return this.checkCoordinator(message.member!);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async chatInputRun(interaction: CommandInteraction) {
|
||||||
|
// for slash command
|
||||||
|
return this.checkCoordinator(interaction.member! as GuildMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async contextMenuRun(
|
||||||
|
interaction: ContextMenuCommandInteraction,
|
||||||
|
) {
|
||||||
|
// for context menu command
|
||||||
|
return this.checkCoordinator(interaction.member! as GuildMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async checkCoordinator(user: GuildMember) {
|
||||||
|
return user.roles.cache.has(IDs.roles.staff.outreachLeader)
|
||||||
|
? this.ok()
|
||||||
|
: this.error({ message: 'Only outreach leaders can run this command!' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@sapphire/framework' {
|
||||||
|
interface Preconditions {
|
||||||
|
OutreachLeaderOnly: never;
|
||||||
|
}
|
||||||
|
}
|
@ -60,6 +60,7 @@ const devIDs = {
|
|||||||
outreachCoordinator: '999431675140382807',
|
outreachCoordinator: '999431675140382807',
|
||||||
mediaCoordinator: '1204801056404676618',
|
mediaCoordinator: '1204801056404676618',
|
||||||
hrCoordinator: '1204795893480431657',
|
hrCoordinator: '1204795893480431657',
|
||||||
|
outreachLeader: '999431675123597409',
|
||||||
restricted: '999431675123597407',
|
restricted: '999431675123597407',
|
||||||
moderator: '999431675123597408',
|
moderator: '999431675123597408',
|
||||||
trialModerator: '999431675123597404',
|
trialModerator: '999431675123597404',
|
||||||
|
@ -62,6 +62,7 @@ let IDs = {
|
|||||||
outreachCoordinator: '954804769476730890',
|
outreachCoordinator: '954804769476730890',
|
||||||
mediaCoordinator: '1203778509449723914',
|
mediaCoordinator: '1203778509449723914',
|
||||||
hrCoordinator: '1203802120180989993',
|
hrCoordinator: '1203802120180989993',
|
||||||
|
outreachLeader: '730915698544607232',
|
||||||
restricted: '851624392928264222',
|
restricted: '851624392928264222',
|
||||||
moderator: '826157475815489598',
|
moderator: '826157475815489598',
|
||||||
trialModerator: '982074555596152904',
|
trialModerator: '982074555596152904',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user