我正在尝试拆分成员提及(消息)和原因(args),但是这样做没有做到:我同时获得了提及和原因,但它提及了成员并将原因放在了理由字段下在嵌入上。
const Discord = require("discord.js");
module.exports = {
name: "kick",
guildOnly: true,
nsfw: false,
description: "Kick a member from the server with or without a reason.",
execute(message, args) {
if (!message.mentions.users.size) {
return message.channel.send("You need to mention a member to kick.");
} else {
const member = message.mentions.members.first();
const reason = args;
const kickEmbed = new Discord.RichEmbed()
.setColor("#ff00ea")
.setAuthor("User Kicked")
.setDescription(member.displayName + " was removed from the server.")
.addField("Assigned by", message.author.username, true)
.addField("Reason", reason, true);
member.kick(reason);
message.channel.send(kickEmbed);
message.react("")
}
}
};
答案 0 :(得分:1)
args
是一个数组,第一个索引包含用户,第二个索引包含您的情况。
这应该可行,这取决于您的输入。
reason = args[1]