I have a little problem. My bot, sometimes sends a message directly to the user, but if user turned off the messages from strangers it crashes, so my question is: Is there some If function that will check if you can send a message to this user? Or maybe some command, that will try to send a message to the user, but if it won’t work, bot will ignore it and go on. Tried “try” but it doesn’t work “DiscordAPIError: Cannot send messages to this user”
try{
await client.users.cache.get(`${id}`).send('hello',{
embed:embed1,
});
let messageEmbed1 = await client.users.cache.get(`${id}`).send({embeds: [embed1]})
} catch (error) {
console.error(error);