diff --git a/packages/misc/commands/reply.ts b/packages/misc/commands/reply.ts index e0f06ef..d4917d0 100644 --- a/packages/misc/commands/reply.ts +++ b/packages/misc/commands/reply.ts @@ -4,6 +4,8 @@ import { LANG, Config, Command, Pager } from 'core'; import { ClientMessageHandler, ReplyPattern } from '../util/messages'; import { feature as perms } from 'perms'; +perms.registerPermission('replyCustomize', '自動応答の設定'); + module.exports = { data: new SlashCommandBuilder() .setName(LANG.commands.reply.name) diff --git a/packages/perms/commands/perm.ts b/packages/perms/commands/perm.ts index 3e24a95..0d1c265 100644 --- a/packages/perms/commands/perm.ts +++ b/packages/perms/commands/perm.ts @@ -1,10 +1,19 @@ import { CompoundCommandBuilder } from 'core'; import { feature as db } from 'db'; -import { PermissionFlagsBits } from 'discord.js'; +import { + ApplicationCommandOptionChoiceData, + PermissionFlagsBits, +} from 'discord.js'; import { PermissionManager } from '../PermissionManager'; const builder = new CompoundCommandBuilder('perm', '権限の設定'); +const choices: ApplicationCommandOptionChoiceData[] = []; + +export function addChoice(choice: ApplicationCommandOptionChoiceData) { + choices.push(choice); +} + builder .subcommand('set', '値の更新') .addStringOption({ @@ -12,12 +21,7 @@ builder description: '権限名', required: true, async autocomplete(interaction) { - await interaction.respond([ - { - name: '自動応答の設定', - value: 'replyCustomize', - }, - ]); + await interaction.respond(choices); }, }) .addMentionableOption({ @@ -57,12 +61,7 @@ builder description: '権限名', required: true, async autocomplete(interaction) { - await interaction.respond([ - { - name: '自動応答の設定', - value: 'replyCustomize', - }, - ]); + await interaction.respond(choices); }, }) .build(async (interaction, permissionName) => { diff --git a/packages/perms/index.ts b/packages/perms/index.ts index fd2af12..c87b9e1 100644 --- a/packages/perms/index.ts +++ b/packages/perms/index.ts @@ -1,6 +1,6 @@ import { CommandManager, Feature } from 'core'; import { Client } from 'discord.js'; -import perm from './commands/perm'; +import perm, { addChoice } from './commands/perm'; import { feature as db } from 'db'; import { PermissionManager } from './PermissionManager'; @@ -20,6 +20,13 @@ class PermsFeature extends Feature { onClientReady(client: Client): void | PromiseLike { this.permissions = PermissionManager.forClient(client); } + + registerPermission(name: string, description: string) { + addChoice({ + name: description, + value: name, + }); + } } export const feature = new PermsFeature();