Skip to content

Command

import { Command } from 'discord-hono'
const commands = [
new Command('name', 'description'),
new Command('ping', 'response pong'),
]

Check the Official Docs for the first argument (name) of Command.

Method

const commands = [
new Command('name', 'description')
.id()
.type(2) // 1,2,3 default 1 --- 1: CHAT_INPUT, 2: USER, 3: MESSAGE
.application_id()
.guild_id()
.name_localizations()
.description_localizations()
.options(
new Option('text', 'first text'),
new Option('second', 'second text'),
)
.default_member_permissions()
.dm_permission()
.nsfw()
.integration_types()
.contexts()
.version(),
]

Please refer to the Official Docs.

Subcommands

import { Command, SubGroup, SubCommand } from 'discord-hono'
const commands = [
new Command('slash', 'slash description').options(
new SubCommand('sub1', 'Subcommand 1'),
new SubGroup('group', 'group description').options(
new SubCommand('sub2', 'Subcommand 2'),
new SubCommand('sub3', 'Subcommand 3'),
),
),
]

Please refer to the Official Docs.

SubCommand.options can be set to the same Command.options.

Options

import {
Command,
Option,
NumberOption,
BooleanOption,
UserOption,
ChannelOption,
RoleOption,
MentionableOption,
AttachmentOption,
} from 'discord-hono'
const commands = [
new Command('ping', 'response pong').options(
new Option('name', 'description'),
new Option('text', 'response text'),
),
]

Each option is available for each type here.
Option is String option.

Method

const commands = [
new Command('ping', 'response pong').options(
new Option('name', 'description')
.name_localizations()
.description_localizations()
.required() // .required(true) = .required()
.choices(
{ name: 'choice 1', value: 'string 1' },
{ name: 'choice 2', value: 'string 2' },
)
.min_length()
.max_length()
.autocomplete(),
),
]

Please refer to the Official Docs.

Depending on the type of option, some fields (methods) cannot be used.