My Bot Can't Add roles to member

My Simple Code
const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require("discord.js");
const { default: axios } = require("axios");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
const role = await interaction.guild.roles.cache.get("1181943769789108255");
await interaction.member.roles.add(role);
await interaction.reply("Hello");
}
const { EmbedBuilder, ButtonStyle, ActionRowBuilder, ButtonBuilder, ModalBuilder, TextInputBuilder, TextInputStyle } = require("discord.js");
const { default: axios } = require("axios");

module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
const role = await interaction.guild.roles.cache.get("1181943769789108255");
await interaction.member.roles.add(role);
await interaction.reply("Hello");
}
DiscordAPIError[50013]: Missing Permissions
at handleErrors (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async GuildMemberRoleManager.add (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:131:7)
at async Object.execute (D:\.Projects\HewkawDiscordBotProject\M2Bot\events\interactionCreateButtons.js:23:13)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/guilds/1121829832423129160/members/758681611251744788/roles/1181943769789108255'
}

Node.js v18.13.0
DiscordAPIError[50013]: Missing Permissions
at handleErrors (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async GuildMemberRoleManager.add (D:\.Projects\HewkawDiscordBotProject\M2Bot\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:131:7)
at async Object.execute (D:\.Projects\HewkawDiscordBotProject\M2Bot\events\interactionCreateButtons.js:23:13)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: { files: undefined, json: undefined },
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PUT',
url: 'https://discord.com/api/v10/guilds/1121829832423129160/members/758681611251744788/roles/1181943769789108255'
}

Node.js v18.13.0
1 Reply
d.js toolkit
d.js toolkit12mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Want results from more Discord servers?
Add your server