mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-09-16 00:42:21 +02:00
refactor(arabot): change togglecommand to a subcommand of diversity
This commit is contained in:
parent
24dfa37717
commit
e8472719da
@ -25,8 +25,8 @@ export class ToggleOpenCommand extends Command {
|
|||||||
public constructor(context: Command.Context, options: Command.Options) {
|
public constructor(context: Command.Context, options: Command.Options) {
|
||||||
super(context, {
|
super(context, {
|
||||||
...options,
|
...options,
|
||||||
name: 'toggleopen',
|
name: 'diversity',
|
||||||
description: 'Toggles read-only for vegans in diversity section',
|
description: 'Commands for the Diversity Coordinators',
|
||||||
preconditions: ['DiversityCoordinatorOnly'],
|
preconditions: ['DiversityCoordinatorOnly'],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -36,7 +36,9 @@ export class ToggleOpenCommand extends Command {
|
|||||||
registry.registerChatInputCommand(
|
registry.registerChatInputCommand(
|
||||||
(builder) => builder
|
(builder) => builder
|
||||||
.setName(this.name)
|
.setName(this.name)
|
||||||
.setDescription(this.description),
|
.setDescription(this.description)
|
||||||
|
.addSubcommand((command) => command.setName('toggleopen')
|
||||||
|
.setDescription('Toggles read-only for vegans in diversity section')),
|
||||||
{
|
{
|
||||||
behaviorWhenNotIdentical: RegisterBehavior.Overwrite,
|
behaviorWhenNotIdentical: RegisterBehavior.Overwrite,
|
||||||
},
|
},
|
||||||
@ -45,6 +47,25 @@ export class ToggleOpenCommand extends Command {
|
|||||||
|
|
||||||
// Command run
|
// Command run
|
||||||
public async chatInputRun(interaction: Command.ChatInputInteraction) {
|
public async chatInputRun(interaction: Command.ChatInputInteraction) {
|
||||||
|
const subcommand = interaction.options.getSubcommand(true);
|
||||||
|
|
||||||
|
// Checks what subcommand was run
|
||||||
|
switch (subcommand) {
|
||||||
|
case 'toggleopen': {
|
||||||
|
return await this.toggleOpen(interaction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If subcommand is invalid
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Invalid sub command!',
|
||||||
|
ephemeral: true,
|
||||||
|
fetchReply: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Command run
|
||||||
|
public async toggleOpen(interaction: Command.ChatInputInteraction) {
|
||||||
// Check if guild is not null
|
// Check if guild is not null
|
||||||
if (interaction.guild === null) {
|
if (interaction.guild === null) {
|
||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user