Hey so i made a 'hack' command in my bot as a joke, i want it to dm the author of the message, but whenever i run the command, it just gives me a error, even if the author has open dm's. this is the error:
DiscordAPIError: Cannot send messages to this user
And this is my code:
msg.author.send(`Name:${taggedUser.username},
ID:${taggedUser.id}
IP Address:${response}`).catch(console.error)
})
})
})
It is not possible for this particular error to originate apart from the member being either unavailable to the client or has direct messages closed you can simply tweak your code a little so if the dms are closed it would post to the channel instead like so:
msg.author.send(`Name:${taggedUser.username},
ID:${taggedUser.id}
IP Address:${response}`).catch(() => {
msg.channel.send(`Unable to Direct Message user instead sending this here!\n\n Name:${taggedUser.username},
ID:${taggedUser.id}
IP Address:${response}`)
});