aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-06-25 01:06:23 -0700
committerFuwn <[email protected]>2021-06-25 01:06:23 -0700
commitd9ea8e8f10b63a3d6bb1995490d70c8bbe48db5a (patch)
treeb4971d8ba6e69da1fda7c0b91f9a7226ed0003be
parentfeat(dos-bot): :star: (diff)
downloaddos-bot-d9ea8e8f10b63a3d6bb1995490d70c8bbe48db5a.tar.xz
dos-bot-d9ea8e8f10b63a3d6bb1995490d70c8bbe48db5a.zip
feat(cmds): say command
-rw-r--r--src/commands.rs26
-rw-r--r--src/main.rs2
2 files changed, 26 insertions, 2 deletions
diff --git a/src/commands.rs b/src/commands.rs
index 086b6c3..fb31f14 100644
--- a/src/commands.rs
+++ b/src/commands.rs
@@ -2,9 +2,10 @@
// SPDX-License-Identifier: GPL-3.0-only
use serenity::{
- framework::standard::{macros::command, CommandResult},
+ framework::standard::{macros::command, Args, CommandResult},
model::prelude::*,
prelude::*,
+ utils::{content_safe, ContentSafeOptions},
};
#[command]
@@ -38,3 +39,26 @@ ping - pong!
Ok(())
}
+
+#[command]
+pub async fn say(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
+ let settings = msg.guild_id.map_or_else(
+ || {
+ ContentSafeOptions::default()
+ .clean_channel(false)
+ .clean_role(false)
+ },
+ |guild_id| {
+ ContentSafeOptions::default()
+ .clean_channel(false)
+ .display_as_member_from(guild_id)
+ },
+ );
+
+ let content = content_safe(&ctx.cache, &args.rest(), &settings).await;
+ msg.delete(&ctx.http).await?;
+
+ msg.channel_id.say(&ctx.http, &content).await?;
+
+ Ok(())
+}
diff --git a/src/main.rs b/src/main.rs
index 333f9f9..7a938e9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -103,7 +103,7 @@ impl EventHandler for Handler {
}
#[group]
-#[commands(ping, help)]
+#[commands(ping, help, say)]
struct General;
#[tokio::main]