This snippets pins a specific message of a channel if the command was used by the role you've set as the environment variable `ADMIN_ROLE`. Remember to register a slash command named "/pin" via the [command builder](https://autocode.com/tools/discord/command-builder/) and make a required option called `message_id`.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let event = context.params.event;
if (event.member.roles.includes(process.env.ADMIN_ROLE)) {
await lib.discord.channels['@0.2.0'].pins.create({
message_id: event.data.options[0].value,
channel_id: event.channel_id,
});
} else {
await lib.discord.users['@0.1.5'].dms.create({
recipient_id: event.member.user.id,
content: `Hey ${event.member.user.username}! You don't have the permission to use the command \`/pin\`.`,
});
}