mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 12:44:17 +02:00
Merge pull request #63 from veganhacktivists/stagehost
feat(arabot): add command to give stage host role
This commit is contained in:
commit
2be5043bf9
100
src/commands/roles/stagehost.ts
Normal file
100
src/commands/roles/stagehost.ts
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// 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 { Command, RegisterBehavior } from '@sapphire/framework';
|
||||||
|
import IDs from '../../utils/ids';
|
||||||
|
|
||||||
|
export class StageHostCommand extends Command {
|
||||||
|
public constructor(context: Command.Context, options: Command.Options) {
|
||||||
|
super(context, {
|
||||||
|
...options,
|
||||||
|
name: 'stagehost',
|
||||||
|
description: 'Gives the Stage Host role',
|
||||||
|
preconditions: ['EventCoordinatorOnly'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registers that this is a slash command
|
||||||
|
public override registerApplicationCommands(registry: Command.Registry) {
|
||||||
|
registry.registerChatInputCommand(
|
||||||
|
(builder) => builder
|
||||||
|
.setName(this.name)
|
||||||
|
.setDescription(this.description)
|
||||||
|
.addUserOption((option) => option.setName('user')
|
||||||
|
.setDescription('User to give Stage Host to')
|
||||||
|
.setRequired(true)),
|
||||||
|
{
|
||||||
|
behaviorWhenNotIdentical: RegisterBehavior.Overwrite,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command run
|
||||||
|
public async chatInputRun(interaction: Command.ChatInputInteraction) {
|
||||||
|
// TODO add database updates
|
||||||
|
// Get the arguments
|
||||||
|
const user = interaction.options.getUser('user');
|
||||||
|
const { guild } = interaction;
|
||||||
|
|
||||||
|
// Checks if all the variables are of the right type
|
||||||
|
if (user === null || guild === null) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Error fetching user!',
|
||||||
|
ephemeral: true,
|
||||||
|
fetchReply: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gets guildMember whilst removing the ability of each other variables being null
|
||||||
|
let guildMember = guild!.members.cache.get(user!.id);
|
||||||
|
let stageHost = guild!.roles.cache.get(IDs.roles.stageHost);
|
||||||
|
|
||||||
|
// Checks if guildMember is null
|
||||||
|
if (guildMember === null || stageHost === undefined) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Error fetching user!',
|
||||||
|
ephemeral: true,
|
||||||
|
fetchReply: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Removes the possibility of guildMember being null
|
||||||
|
guildMember = guildMember!;
|
||||||
|
stageHost = stageHost!;
|
||||||
|
|
||||||
|
// Checks if the user has Veg Curious and to give them or remove them based on if they have it
|
||||||
|
if (guildMember.roles.cache.has(IDs.roles.stageHost)) {
|
||||||
|
// Remove the Veg Curious role from the user
|
||||||
|
await guildMember.roles.remove(stageHost);
|
||||||
|
await interaction.reply({
|
||||||
|
content: `Removed the ${stageHost.name} role from ${user!}`,
|
||||||
|
fetchReply: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Add Veg Curious role to the user
|
||||||
|
await guildMember.roles.add(stageHost);
|
||||||
|
await interaction.reply({
|
||||||
|
content: `Gave ${user!} the ${stageHost.name} role!`,
|
||||||
|
fetchReply: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class CoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
export class CoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class DevCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
export class DevCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class DiversityCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
export class DiversityCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
56
src/preconditions/EventCoordinatorOnly.ts
Normal file
56
src/preconditions/EventCoordinatorOnly.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// 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,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
|
import IDs from '../utils/ids';
|
||||||
|
|
||||||
|
export class EventCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
|
public override async messageRun(message: Message) {
|
||||||
|
// for message command
|
||||||
|
return this.checkEventCoordinator(message.member!);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async chatInputRun(interaction: CommandInteraction) {
|
||||||
|
// for slash command
|
||||||
|
return this.checkEventCoordinator(interaction.member! as GuildMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async contextMenuRun(interaction: ContextMenuInteraction) {
|
||||||
|
// for context menu command
|
||||||
|
return this.checkEventCoordinator(interaction.member! as GuildMember);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async checkEventCoordinator(user: GuildMember) {
|
||||||
|
return user.roles.cache.has(IDs.roles.staff.eventCoordinator)
|
||||||
|
? this.ok()
|
||||||
|
: this.error({ message: 'Only event coordinators can run this command!' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@sapphire/framework' {
|
||||||
|
interface Preconditions {
|
||||||
|
EventCoordinatorOnly: never;
|
||||||
|
}
|
||||||
|
}
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class MentorCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
export class MentorCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class ModOnlyPrecondition extends AllFlowsPrecondition {
|
export class ModOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class PatreonOnlyPrecondition extends AllFlowsPrecondition {
|
export class PatreonOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class VerifierCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
export class VerifierCoordinatorOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -18,9 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AllFlowsPrecondition } from '@sapphire/framework';
|
import { AllFlowsPrecondition } from '@sapphire/framework';
|
||||||
import type { CommandInteraction, ContextMenuInteraction, Message } from 'discord.js';
|
import type {
|
||||||
|
CommandInteraction,
|
||||||
|
ContextMenuInteraction,
|
||||||
|
Message,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
import IDs from '../utils/ids';
|
import IDs from '../utils/ids';
|
||||||
import type { GuildMember } from 'discord.js';
|
|
||||||
|
|
||||||
export class VerifierOnlyPrecondition extends AllFlowsPrecondition {
|
export class VerifierOnlyPrecondition extends AllFlowsPrecondition {
|
||||||
public override async messageRun(message: Message) {
|
public override async messageRun(message: Message) {
|
||||||
|
@ -44,10 +44,12 @@ const devIDs = {
|
|||||||
diversityCoordinator: '999431675140382808',
|
diversityCoordinator: '999431675140382808',
|
||||||
mentorCoordinator: '999431675140382809',
|
mentorCoordinator: '999431675140382809',
|
||||||
verifierCoordinator: '999431675140382810',
|
verifierCoordinator: '999431675140382810',
|
||||||
|
eventCoordinator: '999431675165556817',
|
||||||
restricted: '999431675123597407',
|
restricted: '999431675123597407',
|
||||||
moderator: '999431675123597408',
|
moderator: '999431675123597408',
|
||||||
verifier: '999431675123597406',
|
verifier: '999431675123597406',
|
||||||
},
|
},
|
||||||
|
stageHost: '999431675123597411',
|
||||||
patron: '999431675098447935',
|
patron: '999431675098447935',
|
||||||
patreon: '999431675098447936',
|
patreon: '999431675098447936',
|
||||||
verifyingAsVegan: '999431675081666597',
|
verifyingAsVegan: '999431675081666597',
|
||||||
|
@ -47,10 +47,12 @@ let IDs = {
|
|||||||
diversityCoordinator: '948284375827640321',
|
diversityCoordinator: '948284375827640321',
|
||||||
mentorCoordinator: '947905630939807785',
|
mentorCoordinator: '947905630939807785',
|
||||||
verifierCoordinator: '940721280376778822',
|
verifierCoordinator: '940721280376778822',
|
||||||
|
eventCoordinator: '944732860554817586',
|
||||||
restricted: '851624392928264222',
|
restricted: '851624392928264222',
|
||||||
moderator: '826157475815489598',
|
moderator: '826157475815489598',
|
||||||
verifier: '871802735031373856',
|
verifier: '871802735031373856',
|
||||||
},
|
},
|
||||||
|
stageHost: '854893757593419786',
|
||||||
patron: '765370219207852055',
|
patron: '765370219207852055',
|
||||||
patreon: '993848684640997406',
|
patreon: '993848684640997406',
|
||||||
verifyingAsVegan: '854725899576279060',
|
verifyingAsVegan: '854725899576279060',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user