-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod lighthouse; | ||
pub mod self_timeout; | ||
pub mod suppress_embeds; | ||
pub mod translate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use color_eyre::eyre::Result; | ||
use poise::serenity_prelude as serenity; | ||
|
||
use crate::Context; | ||
|
||
/// Translates a message | ||
#[poise::command(context_menu_command = "Suppress Embeds", guild_only, ephemeral)] | ||
#[allow(clippy::redundant_closure_for_method_calls)] | ||
pub async fn suppress_embeds(ctx: Context<'_>, message: serenity::Message) -> Result<()> { | ||
ctx.defer_ephemeral().await?; | ||
|
||
if ctx.author() == &message.author | ||
|| ctx | ||
.author_member() | ||
.await | ||
.is_some_and(|m| m.permissions(ctx).is_ok_and(|p| p.manage_messages())) | ||
{ | ||
let suppressed = message | ||
.flags | ||
.is_some_and(|flags| flags.contains(serenity::MessageFlags::SUPPRESS_EMBEDS)); | ||
|
||
ctx.http() | ||
.edit_message( | ||
message.channel_id, | ||
message.id, | ||
&serenity::EditMessage::new().suppress_embeds(!suppressed), | ||
Vec::new(), | ||
) | ||
.await?; | ||
|
||
ctx.say(format!( | ||
"Embeds have been {} on this message.", | ||
if suppressed { | ||
"unsuppressed" | ||
} else { | ||
"suppressed" | ||
} | ||
)) | ||
.await?; | ||
} else { | ||
ctx.say("You do not have permissions to suppress embeds on this message!") | ||
.await?; | ||
} | ||
|
||
Ok(()) | ||
} |