【发布时间】:2021-07-19 03:18:00
【问题描述】:
我正在制作一个 discord.js 静音机器人,但遇到了一些问题。
我怎样才能做到这一点,当有人使用命令!mute User 时,它会将时间设置为30min,将原因设置为No reason Specified。
但是如果他们使用!mute @User <Time>,它会将用户指定的时间和原因设置为No reason Specified。
最后,如果他们使用!mute @User <Reason>,它会将时间设置为30min,并在命令中写入原因。
const userx = message.mentions.users.first();
if (!userx) {
message.channel.send("**USAGE: `!mute <User> <Time> <Reason>`");
return;
}
let time = args.slice(1).join(" ");
if (!time) time = "30min";
let reason = args.slice(2).join(" ");
if (!reason) reason = "No reason Specified";
我目前无法理解 args.slice 的工作原理。
【问题讨论】:
-
我修复了消息...该网站删除了 > 之间的内容
-
args是一个数组,所以看Array.slice
标签: javascript node.js discord.js