Command
import { Command } from 'discord-hono'
const commands = [ new Command('name', 'description'), new Command('ping', 'pong を返答'),]
Command
の第1引数については、公式ドキュメントを確認してください。
Method
const commands = [ new Command('name', 'description') .id() .type(2) // 1,2,3 デフォルト 1 --- 1: CHAT_INPUT, 2: USER, 3: MESSAGE .application_id() .guild_id() .name_localizations() .description_localizations() .options( new Option('text', 'テキスト1つ目'), new Option('second', 'テキスト2つ目'), ) .default_member_permissions() .dm_permission() .default_permission() .nsfw() .integration_types() .contexts() .version() .handler(),]
公式ドキュメントを参照してください。
Subcommands
import { Command, SubGroup, SubCommand } from 'discord-hono'
const commands = [ new Command('slash', 'slash description').options( new SubCommand('sub1', 'サブコマンド 1'), new SubGroup('group', 'サブコマンドグループ description').options( new SubCommand('sub2', 'サブコマンド 2'), new SubCommand('sub3', 'サブコマンド 3'), ), ),]
公式ドキュメントを参照してください。
SubCommand.options
には Command.options
と同じものを設定できます。
Options
import { Command, Option } from 'discord-hono'
type OptionType = | 'String' | 'Integer' | 'Number' | 'Boolean' | 'User' | 'Channel' | 'Role' | 'Mentionable' | 'Attachment'
const optionType: OptionType = 'Channel' // デフォルト: 'String'
const commands = [ new Command('hello', 'world を返答').options( new Option('text', 'テキスト入力'), // String オプション new Option('channel', 'チャンネル選択', optionType), // Channel オプション ),]
Method
const commands = [ new Command('ping', 'pong を返答').options( new Option('name', 'description') .name_localizations() .description_localizations() .required() // .required(true) = .required() .choices( { name: '選択肢1', value: 'string 1' }, { name: '選択肢2', value: 'string 2' }, ) // STRING, INTEGER, NUMBER .channel_types() // CHANNEL .min_value() // INTEGER, NUMBER .max_value() // INTEGER, NUMBER .min_length() // STRING .max_length() // STRING .autocomplete(), // STRING, INTEGER, NUMBER ),]
公式ドキュメントを参照してください。
オプションによって使用できないフィールド(メソッド)があります。