Expand description

Prompts to get user’s response interactively.

Examples

This library provides two types of prompts: message-based and reaction-based. An example for both is given below.

Message Prompt

async fn mprompt(ctx: &Context, msg: &Message) -> Result<(), Error> {
    let prompt_msg = ChannelId(7).say(&ctx.http, "What is your favourite colour?").await?;

    // User's optional response to the message.
    let optional_content = message_prompt_content(ctx, &prompt_msg, &msg.author, 30.0).await;

    Ok(())
}

Reaction Prompt

async fn rprompt(ctx: &Context, msg: &Message) -> Result<(), Error> {
    let prompt_msg = ChannelId(7).say(&ctx.http, "Is red your favourite colour?").await?;

    // Result of user's reaction to the prompt.
    let result = yes_or_no_prompt(ctx, &prompt_msg, &msg.author, 30.0).await?;

    Ok(())
}

For more in-depth usage and examples, see individual functions.

Functions

Creates a message prompt to get the next message a user sends.

Creates a message prompt to get the content of the next message a user sends.

Creates a reaction prompt to get user’s reaction.

A special reaction prompt to check if user reacts with yes or no.