Discord doesn't separate the Pin Message
and Delete Message
permissions, so if like the Party Corgi Network Server you want to give people the ability to pin messages while also not allowing them to delete arbitrary messages from other users, you can do it with a bot command.
In our case, we used Rust and Serenity to implement a !pin <message-id>
command as seen here:
Implementing the command requires getting the Message
using the ChannelId
and MessageId
(both as their u64
representations), and then calling .pin()
on the message itself. Note that we're parsing into a u64
from the message contents here, so strings and such would cause either the parse or the get_message
to fail.
#[command]fn pin(ctx: &mut Context,msg: &Message,mut args: Args,) -> CommandResult {let message_id = args.single::<u64>()?;let result = ctx.http.get_message(*msg.channel_id.as_u64(), message_id).and_then(|rmsg| rmsg.pin(&ctx.http));if let Err(e) = result {println!("{}", e);}Ok(())}
Note: to get the message id you must right click on a message and click "Copy ID"
If you don't see the option to Copy ID
you have to enable the developer tools in discord. Go to your user settings, then to the Appearance tab, and scroll to the bottom to see this Developer Mode
toggle.