Home > OS >  Send message to a user when banned on server
Send message to a user when banned on server

Time:10-12

I was moving my client.on("guildBanAdd", function(guild, user){}) event to discord.js v13 from v12 but when user gets banned - it's not sending user a message, can you please tell me what's wrong with my code?

code

Client.on("guildBanAdd", function(guild, user){
const embed = new Discord.MessageEmbed()
.setTitle("You were banned from ${guild.name}!")
.setColor("Red")
.setDescription(text)
user.send(embed)
});

CodePudding user response:

The solution is very simple, you just have to change user.send(embed) to user.send({embeds: [embed]}) but please note that bot won't send a message if a user block messages from users who don't share any servers with them

  • Related