how to add reason in discord.js ban and kick command with commando framework?(如何使用突击队框架在 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 禁止和踢命令中添加原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用突击队框架在 discord.js 禁止和踢命令中
基础教程推荐
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 直接将值设置为滑块 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01