コンテンツにスキップ

v0.x

GET メソッドは影響する可能性が高いです。

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)

Context の統合

const app = new DiscordHono().cron("", async c => {
console.log(c.cronEvent)
console.log(c.interaction)
})

CronContext を type 情報のみに変更

Section titled “CronContext を type 情報のみに変更”

v0.17.0 -> v0.18.0

return c.update().resDefer(c.followupDelete)
return c.update().resDefer(c => c.followup())

v0.16.x 以前 -> v0.18.0

return c.resDeferUpdate(c.followupDelete)
return c.update().resDefer(c => c.followup())

c.req は Hono の c.req と混同される可能性があり、また Discord Bot では Request オブジェクトを扱う必要がないため、削除されました。
もしこの機能がどうしても必要な場合は、代わりに Hono のミドルウェアを利用することを検討してください。
どうしても代替手段が見つからず、c.req が必要な場合は Issue を作成してください。

c.waitUntil() は、その機能が c.resDefer() に含まれており、使用頻度も低かったため削除されました。
代わりに 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.5以前のバージョンでは、followup は POST を通して処理されていました。
v0.16.6以降では、followup は PATCH を通して処理されます。
これは、意図的に複数回 followup を呼び出している場合にのみ互換性を崩す変更となります。
そのような場合は、新しい followup を作成するために c.rest を使用してください。

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' })
const app = factory.discord()
factory.loader(app, Object.values(handlers))
.loader(Object.values(handlers))
export default app

Restにおけるgetメソッドの戻り値

Section titled “Restにおけるgetメソッドの戻り値”
const { result } = await c.rest.get('/applications/@me', [])
const result = await c.rest.get('/applications/@me', []).then(r => r.json())

正規表現キーをサポートしない

Section titled “正規表現キーをサポートしない”

.component() および .modal() では、正規表現キーの代わりに custom_id を使用してください。
正規表現キーをどうしても使用する必要がある場合は、この例を参照してください。

const app = new DiscordHono()
.command(/regex/, c => c.res('regex'))
.command('regex', c => c.res('regex'))
const handler= (c: ComponentContext<Env, 'Button'>) => {
const handler= (c: ComponentContext<Env, Button>) => {
//...
}
const func = (c: CommandContext<Env> | ComponentContext<Env>) => {
//...
if (c instanceof CommandContext)
if (c.interaction.type === 2)
//...
}