-1

I'm making a kick command and I would like the bot private message the user with a message saying they were kicked, the reason why they were kicked and an invite back to the server however whenever it tries to DM either my alt or my friend it doesn't allow for it to happen. I've checked my settings and my alt and friend don't have the bot block, we allow public DMs, No dm scanning and allow for a private message on both the servers the bot is in

//DM User saying they was kicked with an invite
let kUserID = kUser.id
let invite = await message.channel.createInvite({
  maxAge: 86400,
  maxUses: 1
})
kUser.send(`You was kicked from **${message.guild.name}**, for the reason **${kReason} you can rejoin with this link -> ${invite} `)
Syntle
  • 5,168
  • 3
  • 13
  • 34

1 Answers1

0

The reason you are encountering this error is because you're trying to send a message to a user that does not exist in any guilds the bot is in since you kicked them.

Your solution would be to send the message before kicking the user. You can achieve this by using await to ensure the message has been sent to the user before using the kick() method.

await kUser.send(`You was kicked from **${message.guild.name}**, for the reason **${kReason} you can rejoin with this link -> ${invite} `)
kUser.kick()
Syntle
  • 5,168
  • 3
  • 13
  • 34