TypeScript
import { DiscordHono } from 'discord-hono'
type Env = { Bindings: { DB: D1Database }}
const app = new DiscordHono<Env>()app.command('hello', async c => { const db = c.env.DB /* 何かしらの処理 */ return c.res('world!!')})
export default app.var Types
Section titled “.var Types”type Env = { Variables: { OPTION_NAME?: string TEXTINPUT_CUSTOM_ID?: string }}
const app = new DiscordHono<Env>() .command('ping', c => c.res(c.var.OPTION_NAME)) .modal('modal', c => c.res(c.var.TEXTINPUT_CUSTOM_ID))Init Options
Section titled “Init Options”import type { InitOptions } from 'discord-hono'import { DiscordHono } from 'discord-hono'
type Env = { Bindings: { DB: D1Database }}
const options: InitOptions<Env> = { /***/}const app = new DiscordHono<Env>(options)Context, Handler Types
Section titled “Context, Handler Types”ライブラリとして用意していますが、可能な限り createFactory を使い、Context と関係ない部分を切り離すことを推奨します。
import type { AutocompleteContext, AutocompleteHandler, CommandContext, CommandHandler, ComponentContext, ComponentHandler, CronContext, CronHandler, InitOptions, ModalContext, ModalHandler,} from 'discord-hono'