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 /* Perform some operation */ 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”The library includes these types, but we recommend using createFactory whenever possible and separating parts that are not related to the context.
import type { AutocompleteContext, AutocompleteHandler, CommandContext, CommandHandler, ComponentContext, ComponentHandler, CronContext, CronHandler, InitOptions, ModalContext, ModalHandler,} from 'discord-hono'