Skip to content

Commit

Permalink
feat(self-timeout): add reason field
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanccn committed Feb 10, 2024
1 parent b717729 commit 879e3cd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/commands/useful/self_timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::{utils::serenity::unique_username, Context};
pub async fn self_timeout(
ctx: Context<'_>,
#[description = "The duration to time yourself out for"] duration: String,
#[description = "The reason for the timeout"] reason: Option<String>,
) -> Result<()> {
ctx.defer_ephemeral().await?;

Expand Down Expand Up @@ -41,11 +42,15 @@ pub async fn self_timeout(
.await?
.unwrap_or(false)
{
let resp_embed = resp_embed.author(
let mut resp_embed = resp_embed.author(
serenity::CreateEmbedAuthor::new(unique_username(ctx.author()))
.icon_url(ctx.author().face()),
);

if let Some(reason) = reason {
resp_embed = resp_embed.field("Reason", reason, false);
}

ctx.channel_id()
.send_message(&ctx, serenity::CreateMessage::default().embed(resp_embed))
.await?;
Expand Down

0 comments on commit 879e3cd

Please sign in to comment.