crash even if I have a trycatch

The bot crashes even if I put a trycatch(error).
DT
d.js toolkit16d 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!
A
Aiwoz[old]16d ago
Command handler :
try {
member.setNickname(newNickname);
} catch (error) {
console.error( error);
}
try {
member.setNickname(newNickname);
} catch (error) {
console.error( error);
}
Error :
C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:722
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50013]: Missing Permissions
at handleErrors (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async GuildMemberManager.edit (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\discord.js\src\managers\GuildMemberManager.js:381:15) {
requestBody: { files: undefined, json: { nick: 'Test' } },
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PATCH',
url: 'https://discord.com/api/v10/guilds/1187082722401861765/members/693160609398653010'
}

Node.js v20.11.1
C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:722
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
^

DiscordAPIError[50013]: Missing Permissions
at handleErrors (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:1120:23)
at async SequentialHandler.queueRequest (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:953:14)
at async _REST.request (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async GuildMemberManager.edit (C:\Users\Aiwoz\Desktop\Bot Discord\Bot-Aiwoz\node_modules\discord.js\src\managers\GuildMemberManager.js:381:15) {
requestBody: { files: undefined, json: { nick: 'Test' } },
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'PATCH',
url: 'https://discord.com/api/v10/guilds/1187082722401861765/members/693160609398653010'
}

Node.js v20.11.1
G
gwapes16d ago
Need to await the promise
A
Aiwoz[old]16d ago
Okay and if I want an error for all events, I put await in the event handler?
No description
G
gwapes16d ago
No you catch errors where they happen. If you execute a command using <command>.execute(…) then you can add error handling there
A
Aiwoz[old]16d ago
Thank you. ^^
Want results from more Discord servers?
Add your server
More Posts
Trouble with collector and interactionsHere's the part of my code that's causing errors: ```javascript async function handleListReactions(unknown interactionhello everyone i have a ticket bot and when the admin want to close the ticket and press the button What are the exact differences between a Webhook and a Webhook client?I've read the page on the [discordjs.guide](https://discordjs.guide/popular-topics/webhooks.html#whaChecking if a user is mobiile```JS client.on('messageCreate', async (message) => { // Check if the user is online and has preSharding QuestionsHello, As my bot is nearly reaching the 2k servers. I need to prepare it to sharding but I have soRepeating interactionIs there a way to use the 'interaction.update' multiple times? So i can make like one button after aWhat Discord.js features have the potential to hit the limit/go over the set Discord API limits?Where can I even find Discord's API limits? I just want to make sure that what I am doing with my boError when i do npm install discord.jsi don’t know how to fix this at all and i’m beyond confused i’ve tried so many times i am useing VisSimple question, how can I check if an incoming message is *specifically* a slash command?How can I check to see if an incoming message (messageCreate) is a slash command? Sometimes a typo cdiscord voice enginehello im just asking if someone got an alternative discord voice engine that work on windowsDeleting Ephemeral MessagesIs there any sort of way to reply to an interaction privately and then delete the reply?Button Automatically PressingHello! Im currently working on a bot using oauth2. Im in the middle of rewriting how i handle refresBot joins the vc but audio doesn't playyes the path is correct. ```js var { voice } = message.member if(!voice.channelId) return mCommand handler changeWould it be possible (is there an example) of a command handler, that looks into a folder with all o