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'


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);
    }


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.
Was this page helpful?