如何创建 "TempMute" 命令?

How to create a "TempMute" command?

如何为 discord.js 创建一个支持来自 An Idiot's Guide 的命令处理程序的 TempMute 命令。
我知道您需要使用 .addRole(),但我不知道如何使用计时器创建它。计时器的范围需要在 60 到 15 分钟之间。

如果你想让一个动作在一段时间后执行,你需要使用setTimeout()。这是一个例子:

// If the command is like: -tempMute <mention> <minutes> [reason]
exports.run = (client, message, [mention, minutes, ...reason]) => {
  // You need to parse those arguments, I'll leave that to you.

  // This is the role you want to assign to the user
  let mutedRole = message.guild.roles.cache.find(role => role.name == "Your role's name");
  // This is the member you want to mute
  let member = message.mentions.members.first();

  // Mute the user
  member.roles.add(mutedRole, `Muted by ${message.author.tag} for ${minutes} minutes. Reason: ${reason}`);

  // Unmute them after x minutes
  setTimeout(() => {
    member.roles.remove(mutedRole, `Temporary mute expired.`);
  }, minutes * 60000); // time in ms
};

这只是一个伪代码,您需要解析参数并获取角色。