Reputation: 21
When I try to reply to a user with a bot in DM's, I get this error: Discord.Js - Uncaught DiscordAPIError: Cannot send messages to this user
What's the problem?
Code:
client.on('message', message=>{
if(!message.author.send('$$')) return
if(message.author.send('$$')){
message.channel.send('Hi! Please describe your message to get help with it.').catch(error => {
message.channel.send('I was unable to send a message.')
})
}
Upvotes: 0
Views: 833
Reputation: 60
This API error is returned if the user does not accept DMs from accounts that are not in his friends list, blocked etc. Just catch that error and everything will function as it is supposed to - this is not a bug, but a discord API feature.
Edit: There also appears to be a problem with the code itself, it is missing some brackets:
client.on('message', message=> {
if(message.author.bot) return;
if(!message.author.send('$$')) return;
if(message.author.send('$$')){
message.channel.send('Hi! Please describe your message to get help with it.').catch(error => {
message.channel.send('I was unable to send a message.')
})
}
})
Upvotes: 1