feat(discord): Added /social undo command
This commit is contained in:
parent
8453de086a
commit
78e7d9bf23
1 changed files with 42 additions and 1 deletions
|
|
@ -7,7 +7,7 @@ use crate::{Context, Error};
|
||||||
slash_command,
|
slash_command,
|
||||||
required_permissions = "ADMINISTRATOR",
|
required_permissions = "ADMINISTRATOR",
|
||||||
guild_only,
|
guild_only,
|
||||||
subcommands("msg", "edit"),
|
subcommands("msg", "edit", "undo"),
|
||||||
)]
|
)]
|
||||||
pub async fn social( _ctx: Context<'_> ) -> Result<(), Error> {
|
pub async fn social( _ctx: Context<'_> ) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -155,3 +155,44 @@ pub async fn edit (
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[poise::command(
|
||||||
|
prefix_command,
|
||||||
|
slash_command,
|
||||||
|
required_permissions = "ADMINISTRATOR",
|
||||||
|
guild_only,
|
||||||
|
)]
|
||||||
|
pub async fn undo(
|
||||||
|
ctx: Context<'_>,
|
||||||
|
#[rename = "message"]
|
||||||
|
message_id: MessageId,
|
||||||
|
channel: Option<ChannelId>,
|
||||||
|
user: Option<UserId>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
|
||||||
|
if channel.is_none() && user.is_none() {
|
||||||
|
let reply_string = "Please specify channel **or** user".to_string();
|
||||||
|
ctx.reply(reply_string).await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if channel.is_some() && user.is_some() {
|
||||||
|
let reply_string = "Please specify **only** channel or **only** user, not both".to_string();
|
||||||
|
ctx.reply(reply_string).await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(channel) = channel {
|
||||||
|
let message = channel.message(ctx, message_id).await?;
|
||||||
|
message.delete(ctx).await?;
|
||||||
|
} else if let Some(user) = user {
|
||||||
|
let channel = user.create_dm_channel(ctx).await?;
|
||||||
|
let message = channel.message(ctx, message_id).await?;
|
||||||
|
message.delete(ctx).await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let reply_string = "Successfully deleted message".to_string();
|
||||||
|
ctx.reply(reply_string).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue