好的,所以我很难尝试向DM踢出该服务器的用户,因为DM是踢出该成员的人。我不知道我做错了什么,但我希望该机器人向被踢的用户DM,以便他们知道为什么他们被服务器踢了
const { RichEmbed } = require("discord.js")
const { red_dark } = require("../../colors.json");
module.exports = {
name: "kick",
description: "Kick a user from the guild!",
usage: "!kick",
category: "moderation",
accessableby: "Moderator",
aliases: ["k"],
run: async (bot, message, args, user) => {
try{
if (message.member.hasPermission("KICK_MEMBERS")) {
if (message.mentions.users.size != 0) {
if (message.mentions.members.first().kickable) {
let reason = args.slice(1).join(" ")
if(!reason) return message.channel.send("No reason was provided!")
else {
message.member.send("This is a test message")
message.mentions.members.first().kick().then(m => {
message.channel.send(`**${m.user.username}** has been kicked from **${message.guild.name}**. Bye bye!`)
});
}
} else {
message.channel.send(`:x: **${message.mentions.user.first().username}** is too priveledged for me to kick.`);
}
} else {
message.channel.send(':x: Please tag the user you would like to kick.')
}
} else {
message.channel.send(`:x: **${message.author.username}**, You do not have permission to kick. You must have the \`Kick Members\` permission.`);
}
} catch (err) {
message.channel.send(`:x: Either I am unable to kick **${message.mentions.users.first().username},** or I do not have permission to kick members.`);
}
}
}
答案 0 :(得分:0)
您当前将DM发送到message.member
。将其发送给您实际踢过的同一个人(现在与message.mentions.members.first().kick()
一起执行)需要做些什么。
因此,在澄清之后,您需要执行message.mentions.members.first().send("This is a test message")