My Bot Can't Add roles to member

Version - [email protected] - Node.js v18.13.0 My Simple Code
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 { 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");
}
Console
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:8: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:8: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
4 Replies
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
d.js docs
d.js docs12mo ago
- Bots cannot moderate (kick/ban/nickname/...) a target with a higher or equally high highest role or the guild owner. - Bots cannot modify (edit/add/remove) roles that are higher or equally high compared to the bot's highest role. - The Administrator permission does not skip these checks.
HewkawAr
HewkawArOP12mo ago
My Bot Get Administrator Permission And Intents
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildModeration,
]
});
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildModeration,
]
});
treble/luna
treble/luna12mo ago
Read the tag Admin permissions has nothing to do here
Want results from more Discord servers?
Add your server