diff options
| author | Fuwn <[email protected]> | 2021-07-24 12:25:04 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-24 12:25:04 +0000 |
| commit | 2b81b94916c96d0d6cbff62eba0c45d8395b1e5f (patch) | |
| tree | 5a8ac74939fab3fec349590ccebe952655d93009 /src/commands.rs | |
| parent | fix(deps): remove unused (diff) | |
| download | dos-bot-main.tar.xz dos-bot-main.zip | |
Diffstat (limited to 'src/commands.rs')
| -rw-r--r-- | src/commands.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/commands.rs b/src/commands.rs index ee875cb..eddb115 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -9,6 +9,11 @@ use serenity::{ utils::{content_safe, ContentSafeOptions}, }; +fn num_to_emoji(num: i32) -> String { + // Naive + num.to_string() + "️⃣" +} + #[command] pub async fn ping(ctx: &Context, msg: &Message) -> CommandResult { msg.channel_id.say(&ctx.http, "Pong!").await?; @@ -184,3 +189,24 @@ pub async fn count(ctx: &Context, msg: &Message) -> CommandResult { Ok(()) } + +#[command] +pub async fn poll(ctx: &Context, msg: &Message, args: Args) -> CommandResult { + let message = format!("__Poll created by {}__\n\n{}", msg.author.name, args.rest()); + + // let ops = args.rest().split(" "); + // let mut tick = 1; + // for op in ops { + // message += &(num_to_emoji(tick) + " " + op + "\n"); + // tick += 1; + // } + + let sent = msg.channel_id.say(&ctx.http, message).await?; + for i in 1..10 { + sent + .react(&ctx.http, ReactionType::Unicode(num_to_emoji(i))) + .await?; + } + + Ok(()) +} |