I currently have a command to create a bot invite link based on the ID
args provided.
Example: !permissioncalculator 123456789
, where the nine-digit long number stands for the client ID of the discord bot.
This works fine and all, but I made it return the invite link with admin
(one of the possible permissions) or (8)
by default. I want to be able to choose a specific permission name for example MANAGE_MESSAGES
and convert that to a permission number. So you could do !permissioncalculator 123456789 MANAGE_MESSAGES
.
My current code:
const clientid = args.join(" ").slice(9);
const authorizationUrl = `https://discordapp.com/api/oauth2/authorize?client_id=${clientid}&scope=bot&permissions=8`;
let errorEmbed = new Discord.MessageEmbed()
.setColor("#e31212")
.setDescription("ERROR: No valid bot ID entered");
if (!clientid) return message.channel.send(errorEmbed);
let nanEmbed = new Discord.MessageEmbed()
.setColor("#e31212")
.setDescription(
"ERROR: The sequence you have provided is not an integer"
);
if (isNaN(args[1])) return message.channel.send(nanEmbed);
let tooshortid = new Discord.MessageEmbed()
.setColor("#e31212")
.setDescription(
"ERROR: The sequence you have provided is less than 18 digits"
);
if (clientid.length < 18) return message.channel.send(tooshortid);
let authorizationEmbed = new Discord.MessageEmbed()
.setColor("#8f82ff")
.setDescription(
`Here is your invite link for your bot <@${clientid}> \n ${authorizationUrl}`
)
message.channel.send(authorizationEmbed);
I read the Discord Permission Conversion mdn, but I did not find that helpful.