I'm new to slash cmds so this was pretty cool to me, create the command in the slash command builder cmd info here: /addrole and then add a user option and make it required, then add a role option and make it required as well. :) enjoy
// Using Node.js 14.x +
// use "lib" package from npm
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let isADMINISTRATOR =
(context.params.event.member.permissions & (1 << 3)) === 1 << 3;
if (isADMINISTRATOR) {
let role = context.params.event.data.options[1].value;
let user = context.params.event.data.options[0].value;
let result = await lib.discord.guilds['@0.1.3'].members.roles.update({
role_id: `${role}`, // required
user_id: `${user}`, // required
guild_id: `${context.params.event.guild_id}`, // required
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `β
| Role succesfully added to user | Request by ${context.params.event.member.user.username}`,
});
} else {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `β | Role addition Unsuccesful for <@${context.params.event.member.user.id}> | You need the Manage Roles Permission`,
});
}