aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands.rs26
-rw-r--r--src/main.rs2
2 files changed, 27 insertions, 1 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(())
+}
diff --git a/src/main.rs b/src/main.rs
index 3e2bfb7..e859c3d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -96,7 +96,7 @@ impl EventHandler for Handler {
}
#[group]
-#[commands(ping, help, say)]
+#[commands(ping, help, say, poll)]
struct General;
#[group]