GreXLin85
GreXLin85

Reputation: 97

I cant send any messages to users

Hello needed to send PM to users, i tried this command

msg.author.send("text")

But when i tries to run this command i get this error

DiscordAPIError: Cannot send messages to this user
    at RequestHandler.execute (C:\Users\GreXLin85\Desktop\Projelerim\JS\project\node_modules\discord.js\src\rest\RequestHandler.js:154:13)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async RequestHandler.push (C:\Users\GreXLin85\Desktop\Projelerim\JS\project\node_modules\discord.js\src\rest\RequestHandler.js:39:14) {
  method: 'post',
  path: '/channels/782746558520360960/messages',
  code: 50007,
  httpStatus: 403
}

Upvotes: 0

Views: 60

Answers (1)

Bilaboz
Bilaboz

Reputation: 71

There could be multiple reasons:

  1. The user has blocked his DM globally / on this specific server
  2. The user and the bot aren't sharing a server
  3. The user blocked the bot

To avoid this problem you can add a try{} catch{} block

Upvotes: 1

Related Questions