forked from serenity-rs/poise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack_edits.rs
61 lines (49 loc) · 1.85 KB
/
track_edits.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use crate::{Context, Error};
use poise::serenity_prelude as serenity;
#[poise::command(slash_command, prefix_command, reuse_response)]
pub async fn test_reuse_response(ctx: Context<'_>) -> Result<(), Error> {
let image_url = "https://raw.githubusercontent.com/serenity-rs/serenity/current/logo.png";
let reply = {
let embed = serenity::CreateEmbed::default()
.description("embed 1")
.image(image_url);
let components = vec![serenity::CreateActionRow::Buttons(vec![
serenity::CreateButton::new("1")
.label("button 1")
.style(serenity::ButtonStyle::Primary),
])];
poise::CreateReply::default()
.content("message 1")
.embed(embed)
.components(components)
};
ctx.send(reply).await?;
tokio::time::sleep(std::time::Duration::from_secs(2)).await;
let image_url = "https://raw.githubusercontent.com/serenity-rs/serenity/current/examples/e09_create_message_builder/ferris_eyes.png";
let reply = {
let embed = serenity::CreateEmbed::default()
.description("embed 2")
.image(image_url);
let components = vec![serenity::CreateActionRow::Buttons(vec![
serenity::CreateButton::new("2")
.label("button 2")
.style(serenity::ButtonStyle::Danger),
])];
poise::CreateReply::default()
.content("message 2")
.embed(embed)
.components(components)
};
ctx.send(reply).await?;
Ok(())
}
/// Add two numbers
#[poise::command(prefix_command, track_edits, slash_command)]
pub async fn add(
ctx: Context<'_>,
#[description = "First operand"] a: f64,
#[description = "Second operand"] b: f32,
) -> Result<(), Error> {
ctx.say(format!("Result: {}", a + b as f64)).await?;
Ok(())
}