v0.x
v0.22.0
Section titled “v0.22.0”- Removed the class-based builder and switched to function-based builders
- Consolidated builder code
- Strengthened the specificity of the types generated by builders
- Updated related code for builder optimization
Command and Option
Section titled “Command and Option”new Command('autocomplete', 'auto').options( new SubCommand('sub', 'sub command').options( new Option('option', 'op').autocomplete().required(), new Option('option2', 'op2').autocomplete(), ),),makeSlashCommand('autocomplete', 'auto').options([ makeSubCommand('sub', 'sub command').options([ makeStringOption('option', 'op').autocomplete(true).required(true), makeStringOption('option2', 'op2').autocomplete(true), ]),]),Command->makeSlashCommand,makeUserCommand,makeMessageCommand, ormakeEntryPointCommandSubCommand->makeSubCommandSubGroup->makeSubCommandGroupOption->makeStringOption,makeIntegerOption,makeBooleanOption,makeUserOption,makeChannelOption,makeRoleOption,makeMentionableOption,makeNumberOption, ormakeAttachmentOption- Some shorthand syntax has been changed to require explicit, precise declarations
.required()->.required(true); automatic handling oftruehas been removed, so it must be written explicitly.options(option, option, ...)->.options([option, option, ...]); automatic array handling has been removed, so it must be written explicitly
Autocomplete removed
Section titled “Autocomplete removed”c.resAutocomplete( new Autocomplete(c.focused?.value).choices( { name: 'test1', value: 'v-test1' }, { name: 'test2', value: 'v-test2' }, ),),c.resAutocomplete([ { name: 'test1', value: 'v-test1' }, { name: 'test2', value: 'v-test2' },]),This is not exactly the same code.
- Removed custom filtering via the
Autocompleteclass - Extended
resAutocompleteto accept arrays
Component and Button
Section titled “Component and Button”components: new Components().row( new Button('https://discord-hono.luis.fun', ['📑', 'Docs'], 'Link'), component_delete.component,),components: [ makeActionRow([ makeLinkButton('https://discord-hono.luis.fun', ['📑', 'Docs']), component_delete.component, ]),],Components->makeActionRowButton->makeButton,makeLinkButton, ormakePremiumButton
Components V2
Section titled “Components V2”await c.followup( { components: [ new Content('text top'), new Layout('Container').components( new Layout('Action Row').components(component_image_update2.component, component_delete.component), new Layout('Separator'), new Content('container - text'), new Layout('Section') .components(new Content('container - section - text'), new Content('container - section - text2')) .accessory(new Content('image.webp', 'Thumbnail')), new Content('container - text2'), new Content('image.webp', 'Media Gallery'), ), makeTextDisplay('text top'), makeContainer([ makeActionRow([component_image_update2.component, component_delete.component]), makeSeparator(), makeTextDisplay('container - text'), makeSection( [makeTextDisplay('container - section - text'), makeTextDisplay('container - section - text2')], makeThumbnail('attachment://image.webp'), ), makeTextDisplay('container - text2'), makeMediaGallery(['attachment://image.webp']), ]), ], }, { blob, name: 'image.webp' },)Content->makeTextDisplay,makeThumbnail,makeMediaGallery, ormakeFileLayout->makeActionRow,makeSection,makeSeparator,makeContainer, ormakeLabel
new Modal('modal', 'Modal Test') .row(new TextInput('modal_text', 'Modal Text').required()) .component('Channel Select', new Select('channel', 'Channel'))makeModal('modal', 'Modal Test', [ makeActionRow([makeTextInput('modal_text', 'Modal Text').required(true)]), makeLabel('Channel Select', makeChannelSelect('channel')),]),Modal->makeModal,makeActionRow, andmakeLabelTextInput->makeTextInput
new Embed()makeEmbed()new Poll() .question('What is your favorite color?') .answers(['🔴', 'Red'], ['🟢', 'Green'], 'Blue', 'Yellow') .allow_multiselect() .duration(1)makePoll( 'What is your favorite color?', [['🔴', 'Red'], ['🟢', 'Green'], 'Blue', 'Yellow']) .allow_multiselect(true) .duration(1)factory.command<{ text: string }>(...)factory.command<any, { text: string }>(...)- The first argument’s type inference was changed, so part of the type parameters now needs to be handled with
anyor similar.
v0.21.0
Section titled “v0.21.0”- Add
c.refas a quick reference - Handle
custom_idmore consistently and reassign the previous role ofcustom_idtocustom_value - Swap the
$and_in the rest path
c.keyc.ref.keyc.var.custom_idc.ref.custom_valuec.var.xxx (select values)c.ref.values(Button or Select).custom_id(Button or Select).custom_valueawait c.rest('POST', _channels_$_messages, [channel], { content: 'this is rest' })await c.rest('POST', $channels$_$messages, [channel], { content: 'this is rest' })v0.20.0
Section titled “v0.20.0”Coding changes for rest query
Section titled “Coding changes for rest query”GET methods are highly likely to be affected.
await c.rest( 'GET', _channels_$_messages, [channel_id], { limit: 10 }, [channel_id, { limit: 10 }],)await c.rest('METHOD', 'PATH', ['PATH_VAR'], DATA_OBJ or QUERY_OBJ)await c.rest('METHOD', 'PATH', ['PATH_VAR', QUERY_OBJ], DATA_OBJ)v0.19.0
Section titled “v0.19.0”Context integration
c.cronEvent -> c.interaction
Section titled “c.cronEvent -> c.interaction”const app = new DiscordHono().cron("", async c => { console.log(c.cronEvent) console.log(c.interaction)})CronContext changed to type information only
Section titled “CronContext changed to type information only”v0.18.0
Section titled “v0.18.0”Removed c.followupDelete
Section titled “Removed c.followupDelete”v0.17.0 -> v0.18.0
return c.update().resDefer(c.followupDelete)return c.update().resDefer(c => c.followup())Before v0.16.x -> v0.18.0
return c.resDeferUpdate(c.followupDelete)return c.update().resDefer(c => c.followup())v0.17.0
Section titled “v0.17.0”Removed c.req, c.waitUntil()
Section titled “Removed c.req, c.waitUntil()”Since c.req could be confused with Hono’s c.req, and because handling Request objects is not necessary for Discord Bots, it has been removed.
If you absolutely need this functionality, please consider using Hono middleware instead.
If you cannot find an alternative and require c.req, please create an issue.
c.waitUntil() has been removed as its functionality is included in c.resDefer(), and its usage frequency was low.
Instead, please use c.executionCtx.waitUntil().
c.waitUntil(/*process*/)c.executionCtx.waitUntil(/*process*/)c.resUpdate(), c.resDeferUpdate() -> c.update()
Section titled “c.resUpdate(), c.resDeferUpdate() -> c.update()”return c.resUpdate("update text")return c.update().res("update text")return c.resDeferUpdate("update text")return c.update().resDefer("update text")c.suppressEmbeds(), c.ephemeral(), c.suppressNotifications() -> c.flags()
Section titled “c.suppressEmbeds(), c.ephemeral(), c.suppressNotifications() -> c.flags()”return c.ephemeral().suppressNotifications().res("ephemeral text")return c.flags("EPHEMERAL", "SUPPRESS_NOTIFICATIONS").res("ephemeral text")v0.16.6
Section titled “v0.16.6”Unintentional breaking change caused by a developer implementation mistake
fix: c.followup
Section titled “fix: c.followup”In versions prior to v0.16.5, followups were handled via POST.
From v0.16.6 onwards, followups are handled via PATCH.
This is a breaking change only if you are intentionally calling followup multiple times.
In such cases, please use c.rest to create a new followup.
v0.16.0
Section titled “v0.16.0”Rest -> createRest
Section titled “Rest -> createRest”const rest = new Rest('token')const rest = createRest('token')const res = c.rest.post(_channels_$_messages, [channel_id], { content: 'this is rest' })const res = c.rest('POST', _channels_$_messages, [channel_id], { content: 'this is rest' })v0.15.0
Section titled “v0.15.0”factory.loader -> app.loader
Section titled “factory.loader -> app.loader”const app = factory.discord() factory.loader(app, Object.values(handlers)) .loader(Object.values(handlers))export default appv0.14.0
Section titled “v0.14.0”Return value of get method in Rest
Section titled “Return value of get method in Rest”const { result } = await c.rest.get('/applications/@me', [])const result = await c.rest.get('/applications/@me', []).then(r => r.json())v0.13.0
Section titled “v0.13.0”Unsupport regex keys
Section titled “Unsupport regex keys”For .component() and .modal(), please use custom_id instead of regex keys.
If you absolutely need to use regex keys, please refer to this example.
const app = new DiscordHono() .command(/regex/, c => c.res('regex')) .command('regex', c => c.res('regex'))Type change for ComponentContext
Section titled “Type change for ComponentContext”const handler= (c: ComponentContext<Env, 'Button'>) => {const handler= (c: ComponentContext<Env, Button>) => { //...}v0.12.0
Section titled “v0.12.0”Context integration
Section titled “Context integration”const func = (c: CommandContext<Env> | ComponentContext<Env>) => { //... if (c instanceof CommandContext) if (c.interaction.type === 2) //...}