I am making a discord.js
bot for a server I am in, but after attempting to send a DM to a user (who was just kicked, to notify them of it,) the bot won't send it at all and it will spit out an error,
"UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user"
its out of control now, because it will work, I'll add a small something, it will STOP working (more or less expected) and then when I revert that addition it will spit out the error again.
Here is my code for the kick command
const Discord = require("discord.js");
const Client = new Discord.Client
const prefix = "m!"
module.exports.run = async(bot, message, args) => {
params = message.content.slice(prefix.length).trim().split(/ +/g);
command = args.shift().toLowerCase();
let memberKick = message.mentions.members.first();
let reasonKick = args.slice(1).join(" ");
if(message.member.roles.find("name", "MedaFrost Controller")) {
var userReslv = message.guild.members.find("id", memberKick.id);
let usericon = memberKick.displayAvatarURL;
let botembed = new Discord.RichEmbed
botembed.setDescription("β You Were Kicked From Roscord!");
botembed.setColor("FF0000");
botembed.setThumbnail(usericon);
botembed.addField("Reason:", `${reasonKick}`);
userReslv.send(botembed);
memberKick.kick(reasonKick);
message.channel.send("β
" + `${memberKick}` + " was kicked! β
")
} else {
const userId = message.member.id
message.channel.send("Sorry, " + `<@${userId}>` + ", but you do not have sufficient permissions!")
}
}
module.exports.help = {
name: "kickplayer",
description: "Kicks mentioned user."
}
(Proof that the emoji is not the problem) Link to image:
await(100)
? Where is that coming from? β zero298