【问题标题】:how to add reason in discord.js ban and kick command with commando framework?如何使用突击队框架在 discord.js 禁止和踢命令中添加原因?
【发布时间】:2020-12-06 04:23:13
【问题描述】:

我目前正在开发一个带有突击队的discord.js bot(这是 discord.js 创建者的官方框架/命令处理程序)
我在各种网站上研究过这个主题,但我的突击队框架似乎没有任何效果。
这是代码

const Commando = require("discord.js-commando");

module.exports = class banCommands extends (
  Commando.Command
) {
  constructor(client) {
    super(client, {
      name: "ban",
      aliases: ["bans"],
      group: "general",
      memberName: "ban",
      description: "Banned the mention member from the server",
    });
  }
  run(message) {
    const target = message.mentions.users.first();
    if (!target) {
      message.reply("you need to have at least one users mentioned");
      return;
    }
    const { guild } = message;
    const member = guild.members.cache.get(target.id);
    if (member.bannable) {
      guild.members.ban(member);
      message.reply("That user has been banned");
    } else {
      message.reply("You cannot ban that user.");
      console.log(target);
    }
  }
};

有什么建议吗?或任何具有相同主题的东西?

谢谢

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    您需要将它放在options 参数中(请参阅docs)。您也应该使用member.ban 而不是guild.members.ban(member),但无论如何,这里有一个例子:

    member.ban({
        reason: "Your reason here"
    });
    

    并且该成员将被禁止,审核日志中的推理会正确显示。您还应该在命令中添加 reason 参数。不要问我怎么回事,我已经有一年没有接触过 discord.js 了,尤其是突击队。检查指南。提及第一个论点,然后提及原因。

    【讨论】:

      猜你喜欢
      • 2021-04-03
      • 2020-10-20
      • 2020-11-18
      • 2021-06-01
      • 2019-02-15
      • 2019-09-03
      • 1970-01-01
      • 2021-10-06
      • 2021-06-01
      相关资源
      最近更新 更多