Creates a `!verify` prefix command that adds a specific role to the user then deletes their message. This can be used to ensure users read the rules before having more permissions for example.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const {
guild_id,
channel_id,
id: message_id,
content,
author,
} = context.params.event;
// ** DEV ** Update constants here
const role_id = process.env.VERIFIED_ROLE_ID;
const command = '!verify';
// Is this our command?
if (content !== command) return;
// Add the role
await lib.discord.guilds['@0.1.0'].members.roles.update({
guild_id,
role_id,
user_id: author.id,
});
// Delete the message
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id,
message_id,
});