So I was trying to code my bot to add a role to someone who doesn't have that role.... the rest of the code was working fine until I added the member.roles.add command.
It says Missing Permission
however the bot has every possible permission on the server.
module.exports = {
name: 'ping',
description: "this is a ping command!",
execute(message, args) {
if (message.member.roles.cache.has('754222099219873974')) {
message.channel.send('pong');
}
else {
message.channel.send('I see you do not have the right permission to use that command, let me change that for you :)');
message.member.roles.add('754222099219873974');
}
}
}
This is the entire code for one command.
Below is the error I get from the command terminal
(node:68344) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
at RequestHandler.execute (C:\Users\Amit\Desktop\Discord\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:68344) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function
without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:68344) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.