GramIO API Reference / @gramio/prompt/dist
@gramio/prompt/dist
Interfaces
| Interface | Description |
|---|---|
| PromptFunction | Send message and wait answer |
| PromptFunctionParams | Make some keys optional |
| PromptOptions | - |
| PromptPluginTypes | - |
| WaitFunction | Wait for the next event from the user |
| WaitWithActionFunction | - |
Type Aliases
| Type Alias | Description |
|---|---|
| EventsUnion | - |
| MaybeArray | - |
| OnValidateErrorFunction | - |
| PromptAnswer | - |
| PromptsType | - |
| Stringable | - |
| TimeoutStrategy | - |
| TransformFunction | - |
| ValidateFunction | - |
Functions
prompt()
prompt<
GlobalData>(options?):Plugin<{prompt-cancel:PromptCancelError; },DeriveDefinitions&object>
Defined in: prompt/index.d.ts:153
Prompt plugin
Type Parameters
| Type Parameter | Default type |
|---|---|
GlobalData | never |
Parameters
| Parameter | Type |
|---|---|
options? | PromptOptions<GlobalData> |
Returns
Plugin<{ prompt-cancel: PromptCancelError; }, DeriveDefinitions & object>
Example
ts
import { Bot, format, bold } from "gramio";
import { prompt } from "@gramio/prompt";
const bot = new Bot(process.env.token!)
.extend(prompt())
.command("start", async (context) => {
const answer = await context.prompt(
"message",
format`What's your ${bold`name`}?`
);
return context.send(`✨ Your name is ${answer.text}`);
})
.onStart(console.log);
bot.start();