問(wèn)題描述
我目前正在開(kāi)發(fā)一個(gè)帶有 commando 的 discord.js
機(jī)器人(這是 discord.js 創(chuàng)建者的官方框架/命令處理程序)
我在各種網(wǎng)站上研究過(guò)這個(gè)主題,但我的突擊隊(duì)框架似乎沒(méi)有任何效果.
這是代碼
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
參數(shù)中(參見(jiàn) docs).您也應(yīng)該使用 member.ban
而不是 guild.members.ban(member)
,但無(wú)論如何,這里有一個(gè)例子:
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"
});
并且該成員將被禁止,審核日志中的推理會(huì)正確顯示.您還應(yīng)該在命令中添加 reason
參數(shù).不要問(wèn)我怎么回事,我已經(jīng)有一年沒(méi)有接觸過(guò) discord.js 了,尤其是突擊隊(duì).檢查指南.提及第一個(gè)論點(diǎn),然后提及原因.
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.
這篇關(guān)于如何使用突擊隊(duì)框架在 discord.js 禁止和踢命令中添加原因?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!