GramIO API Reference / @gramio/autoload/dist
@gramio/autoload/dist
Interfaces
| Interface | Description |
|---|---|
| AutoloadOptions | Options for autoload plugin with options for Options | fdir and PicomatchOptions | picomatch |
| AutoloadOptionsPathParams | Params that used in onLoad and onFinish hooks |
Functions
autoload()
autoload(
options?):Promise<Plugin<{ },DeriveDefinitions, { }>>
Defined in: autoload/index.d.ts:81
Autoload commands plugin for GramIO.
Parameters
| Parameter | Type |
|---|---|
options? | AutoloadOptions |
Returns
Promise<Plugin<{ }, DeriveDefinitions, { }>>
Example
Register the plugin
ts
// index.ts
import { Bot } from "gramio";
import { autoload } from "@gramio/autoload";
const bot = new Bot(process.env.TOKEN as string)
.extend(autoload())
.onStart(console.log);
bot.start();
export type BotType = typeof bot;Create command
ts
// commands/command.ts
import type { BotType } from "..";
export default (bot: BotType) =>
bot.command("start", (context) => context.send("hello!"));