如何使用突击队框架在 discord.js 禁止和踢命令中添加原因?

how to add reason in discord.js ban and kick command with commando framework?(如何使用突击队框架在 discord.js 禁止和踢命令中添加原因?)
本文介绍了如何使用突击队框架在 discord.js 禁止和踢命令中添加原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

I'm currently working on a discord.js bot with commando (which is the official framework/commands handler from the discord.js creator)
I have researched this subject on various websites and nothing seems to work with my commando framework.
This is the code

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);
    }
  }
};

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

Any suggestion? or anything that have the same subject?

谢谢

推荐答案

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

You'll need to put it in the options argument (see the docs). You should also probably use member.ban instead of guild.members.ban(member), but anyways, here's an example:

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

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

And the member will be banned, with the reasoning in audit logs showing up properly. You should add an reason argument to your command as well. Don't ask me how though, I haven't touched discord.js in a year and especially not commando. Check the guide for that. Make the mention the first argument and the reason the rest.

这篇关于如何使用突击队框架在 discord.js 禁止和踢命令中添加原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)
getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)