diff options
| -rw-r--r-- | src/commands.rs | 26 | ||||
| -rw-r--r-- | src/main.rs | 2 |
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] |