From b5c2cae5617a7d2745ca5aa67007fbf64003ea1d Mon Sep 17 00:00:00 2001 From: kazukazu123123 <50506519+kazukazu123123@users.noreply.github.com> Date: Wed, 10 May 2023 16:33:33 +0900 Subject: [PATCH] Add reset command (#517) --- src/commands/reset.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/commands/reset.ts diff --git a/src/commands/reset.ts b/src/commands/reset.ts new file mode 100644 index 00000000..ae0d1dc5 --- /dev/null +++ b/src/commands/reset.ts @@ -0,0 +1,42 @@ +import { Command, type ChatInputCommand } from '@sapphire/framework' +import { guildCtxManager, workerClientMap } from '../index.js' +import { PermissionFlagsBits } from 'discord.js' + +export class ResetCommand extends Command { + public constructor( + context: ChatInputCommand.Context, + options: ChatInputCommand.Options, + ) { + super(context, { + ...options, + description: + 'このサーバーでの参加状態を初期化します。(⚠VCからBOTが退出します。)', + }) + } + + public override registerApplicationCommands( + registry: ChatInputCommand.Registry, + ) { + registry.registerChatInputCommand((builder) => + builder + .setName(this.name) + .setDescription(this.description) + .setDefaultMemberPermissions(PermissionFlagsBits.MoveMembers) + .setDMPermission(false), + ) + } + public override async chatInputRun( + interaction: ChatInputCommand.Interaction, + ) { + if (!interaction.inCachedGuild()) return + await guildCtxManager.get(interaction.guild).resetBots(workerClientMap) + return interaction.reply({ + embeds: [ + { + color: 0x00ff00, + title: `参加状態を初期化しました。`, + }, + ], + }) + } +}