Skip to content

GramIO API Reference / @gramio/prompt/dist

@gramio/prompt/dist

Interfaces

InterfaceDescription
PromptFunctionSend message and wait answer
PromptFunctionParamsMake some keys optional
PromptOptions-
PromptPluginTypes-
WaitFunctionWait for the next event from the user
WaitWithActionFunction-

Type Aliases

Type AliasDescription
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 ParameterDefault type
GlobalDatanever

Parameters

ParameterType
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();