0
votes

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.')
        })
    }
1
They either blocked you or are not accepting dms from non-friendsLioness100
I allowed the messages and it's still showing this error...Fatal

1 Answers

1
votes

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.')
        })
    }
})