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: `参加状態を初期化しました。`, + }, + ], + }) + } +}