VPS turns off after discord bot didnt get permissions to send messages in a server.

im getting this error :
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1189190604203233390/messages'
rawError: { message: 'Missing Permissions', code: 50013 },
code: 50013,
status: 403,
method: 'POST',
url: 'https://discord.com/api/v10/channels/1189190604203233390/messages'
this is my error handling code :
try {
await handleBotResponse(message, contentWithoutMention); // Moved bot response handling here
} catch (error) {
console.error('Error:', error);

if (error.response && error.response.status === 403) {
// Handle Missing Permissions error (code 50013) by logging without stopping the bot
console.error('Bot is missing permissions in this channel');
message.channel.send('Sorry, I don\'t have the necessary permissions to respond in this channel.');
} else {
// Log other errors and inform the user
console.error('Unhandled error occurred:', error);
message.channel.send('Sorry, I encountered an error while processing your request.');
}
}
}
} catch (outerError) {
console.error('Unhandled exception in messageCreate event handler:', outerError);
}
try {
await handleBotResponse(message, contentWithoutMention); // Moved bot response handling here
} catch (error) {
console.error('Error:', error);

if (error.response && error.response.status === 403) {
// Handle Missing Permissions error (code 50013) by logging without stopping the bot
console.error('Bot is missing permissions in this channel');
message.channel.send('Sorry, I don\'t have the necessary permissions to respond in this channel.');
} else {
// Log other errors and inform the user
console.error('Unhandled error occurred:', error);
message.channel.send('Sorry, I encountered an error while processing your request.');
}
}
}
} catch (outerError) {
console.error('Unhandled exception in messageCreate event handler:', outerError);
}
is my bot going offline after permissions error my VPS fault or discord.js's fault?? i am so confused i just want it to log it in console or the channel that it is missing permissions and continue working and not going offline instantly.
6 Replies
d.js toolkit
d.js toolkit11mo 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!
Yinoguns
Yinoguns11mo ago
You can also check the permissions Member (including the bot) has for a channel to try and avoid this happening, and alert yourself in other ways; such as if you start sending messages to servers.
ekansh
ekanshOP11mo ago
i removed the code and it didnt change anything it still made the bot go offline no my main question is if its possible for the bot to stop going offline when it has any errors like this
Yinoguns
Yinoguns11mo ago
It might be possible with some form of global listener...but even if it is, it'd be my recommendation to defensivly code and account for the perms being missing. If you ignore all errors through a global catcher, you'll end up not knowing when things stop working.
ekansh
ekanshOP11mo ago
sorry my english a bit off what do you mean by defensively coding and account for the perms?
Yinoguns
Yinoguns11mo ago
So instead of catching all errors, try and avoid them. Check if the Bot has perms, don't just catch if it doesn't
Want results from more Discord servers?
Add your server