Function serenity_utils::prompt::message_prompt
source · [−]pub async fn message_prompt(
ctx: &Context,
msg: &Message,
user: &User,
timeout: f32
) -> Option<Message>
Expand description
Creates a message prompt to get the next message a user sends.
Only messages sent in the channel of the original message are considered.
The bot waits for a message for timeout
seconds only. None
is returned
if the user does not send another message.
Example
async fn prompt(ctx: &Context, msg: &Message) -> Result<(), Error> {
// Assuming `channel_id` is bound.
let prompt_msg = ChannelId(7).say(&ctx.http, "What is your favourite colour?").await?;
// Optional `Message` object of user's response to the message.
let optional_msg = message_prompt(ctx, &prompt_msg, &msg.author, 30.0).await;
Ok(())
}
See message_prompt_content
if you only need the message’s content.