所以我需要将!! ban [user] [length] [reason]命令放入3个变量中。如下所示:
run: async(message, client, args) => {
let banned = message.mentions.users.first() || client.users.resolve(args[0]);
const time = args.shift(2)
const reason = args.slice(1).join(' ');
经过一些代码后,我们可以理解这一点:
message.guild.members.ban(banned, { reason: reason });
let successfullyembed = new discord.MessageEmbed()
.setTitle('Successfully banned!')
.setDescription(`${banned.tag} has been successfully banned.`)
.addFields(
{ name: `Reason: ${reason}`, value: `Ban Length: ${time}`, inline: false },
)
.setColor("#2C2F33");
message.channel.send(successfullyembed);
它的嵌入看起来像这样:
Successfully banned!
CandyMan#6411 has been successfully banned.
Reason: 3h s;egjf bs;g;sgbn s;jknghkjnh \nih\se
Ban Length: undefined
我知道一开始它与args有关,但是我对JS比较陌生,我无法查明原因。