Hello I am currently attempting to catch a discord api error with the try catch statement
However for some reason this does not work and my app still stops executing and gives me the following message
There was an uncaught error DiscordAPIError: Cannot send messages to this user // Example
How do I catch api errors with a try and catch block and I cannot use a .catch expression after calling the function
Here is my code
try {
interaction.user.send("Remember")
}
catch(DiscordAPIError) {
console.log("Oh no")
}
If you want to use a synchronous try/catch block, you need to put it in an async function and await the promise from interaction.user.send:
await interaction.user.send("Remember")