mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 06:24:15 +02:00
feat(arabot): add create event to outreach command
This commit is contained in:
parent
e0c609cf69
commit
b87c28061a
97
src/commands/outreach/outreach.ts
Normal file
97
src/commands/outreach/outreach.ts
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Subcommand } from '@sapphire/plugin-subcommands';
|
||||||
|
import { RegisterBehavior } from '@sapphire/framework';
|
||||||
|
import { updateUser } from '#utils/database/dbExistingUser';
|
||||||
|
import { createEvent } from '#utils/database/outreach';
|
||||||
|
|
||||||
|
export class OutreachCommand extends Subcommand {
|
||||||
|
public constructor(context: Subcommand.Context, options: Subcommand.Options) {
|
||||||
|
super(context, {
|
||||||
|
...options,
|
||||||
|
name: 'outreach',
|
||||||
|
description: 'Tools for doing outreach',
|
||||||
|
subcommands: [
|
||||||
|
{
|
||||||
|
name: 'event',
|
||||||
|
type: 'group',
|
||||||
|
entries: [
|
||||||
|
{ name: 'create', chatInputRun: 'eventCreate' },
|
||||||
|
{ name: 'start', chatInputRun: 'eventStart' },
|
||||||
|
{ name: 'end', chatInputRun: 'eventEnd' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
preconditions: ['ModOnly'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Registers that this is a slash command
|
||||||
|
public override registerApplicationCommands(registry: Subcommand.Registry) {
|
||||||
|
registry.registerChatInputCommand(
|
||||||
|
(builder) => builder
|
||||||
|
.setName(this.name)
|
||||||
|
.setDescription(this.description)
|
||||||
|
.addSubcommandGroup((group) => group.setName('event')
|
||||||
|
.setDescription('Commands to do with outreach events')
|
||||||
|
.addSubcommand((command) => command.setName('create')
|
||||||
|
.setDescription('Start an outreach event')
|
||||||
|
.addBooleanOption((option) => option.setName('start')
|
||||||
|
.setDescription('Start the event immediately')))
|
||||||
|
.addSubcommand((command) => command.setName('start')
|
||||||
|
.setDescription('Start an outreach event'))
|
||||||
|
.addSubcommand((command) => command.setName('end')
|
||||||
|
.setDescription('End an outreach event'))),
|
||||||
|
{
|
||||||
|
behaviorWhenNotIdentical: RegisterBehavior.Overwrite,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async eventCreate(interaction: Subcommand.ChatInputCommandInteraction) {
|
||||||
|
// const start = interaction.options.getBoolean('start');
|
||||||
|
const modInteraction = interaction.member;
|
||||||
|
const { guild } = interaction;
|
||||||
|
|
||||||
|
if (modInteraction === null || guild === null) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Mod or guild was not found!',
|
||||||
|
fetchReply: true,
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mod = guild.members.cache.get(modInteraction.user.id);
|
||||||
|
|
||||||
|
if (mod === undefined) {
|
||||||
|
await interaction.reply({
|
||||||
|
content: 'Mod was not found!',
|
||||||
|
fetchReply: true,
|
||||||
|
ephemeral: true,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await updateUser(mod);
|
||||||
|
|
||||||
|
await createEvent(modInteraction.user.id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user