【发布时间】:2021-10-04 17:29:48
【问题描述】:
您好,我正在处理我的 kick 命令,但遇到了这个错误:
(node:2559) UnhandledPromiseRejectionWarning: RangeError [BITFIELD_INVALID]: Invalid bitfield flag or number.
at Function.resolve (/rbd/pnpm-volume/cad5e42d-dfa3-46df-b985-a6e43aa649d2/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/util/BitField.js:150:19)
at Permissions.has (/rbd/pnpm-volume/cad5e42d-dfa3-46df-b985-a6e43aa649d2/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/util/BitField.js:45:28)
at Permissions.has (/rbd/pnpm-volume/cad5e42d-dfa3-46df-b985-a6e43aa649d2/node_modules/.registry.npmjs.org/discord.js/12.5.3/node_modules/discord.js/src/util/Permissions.js:45:85)
我想为我的静音命令设置一个静音角色,这是我的命令:
const Discord = require('discord.js')
exports.run = async (bot, message, args) => {
//console.log(message.member)
const permissions = message.channel.permissionsFor(message.client.user);
let perm=message.channel.permissionsFor(message.member)//perm.has()
if(!permissions.has("KICK_MEMBERS")) return message.noMentionReply(`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" | I don't have permission to kick!!!");
if (!perm.has("KICK_MEMBERS")&&!perm.has("MANAGE_GUILD")&&!perm.has("MANAGE_MEMBERS")&&!perm.has("ADMINISTRATOR"))
return message.mentionReply(`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" | You don't have permission to kick!!!");
if (!args[0]) {
return message.mentinReply(
`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" |Please mention or give the id of the person who you want to kick"
);
}
let target = await message.guild.members.fetch(args[0].replace("<@!", "").replace("<@","").replace(">","")).catch(err => { return message.mentionReply(`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" | Unable to find this Person") });
if (target === !args[0]) {
return message.mentionReply(
`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" | Please mention or give the id of the person who you want to kick"
);
}
if (target.id === message.author.id) {
return message.mentionReply(`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" | You can not kick yourself");
}
let tar=message.channel.permissionsFor(target)//perm.has()
if (tar.has("ADMINISTRATOR")){
return message.mentionReply(`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+" | The user you want to kick is a moderator/administrator I can't do that,try to kick him/her/them yourself..");
}
let BotRole = message.guild.member(message.guild.me).roles.highest.position;
let Role = target.roles.highest.position;
let UserRole = message.member.roles.highest.position;
if (UserRole <= Role) return message.mentionReply(`${process.env.EMOTE_NO || '<:tairitsuno:869919370208509962>'}`+' | You can\'t kick that user because that user has a role position which is higher than yours, or has a same role position as you!');
let reason = args.slice(1).join(" ");
if (!reason) reason = "-";
message.noMentionReply("kicking...")
.then(msg => {
let reasonb = args.slice(1).join(" ");
target.kick({reason: reason+` || by ${message.member.user.tag}`});
if(!reasonb){
msg.edit(`${process.env.EMOTE_OK || '<:hikariok:869920204786925608>'} | Kicked sucessfully`)
};
if(reasonb) {
msg.edit(`${process.env.EMOTE_OK || '<:hikariok:869920204786925608>'} | Kicked sucessfully **|** ${reason}`);}
});
}
exports.info = {
name: 'kick',
aliases:[],
usage: "<user_id_or_mention>",
description: "kicks a member"
}//checked
exports.conf={
cooldown: 0,
dm: "no"
}
我不知道如何解决它,请帮助我
【问题讨论】:
-
查看此链接以获取所有有效的权限标志 - 请注意
MANAGE_MEMBERS不是其中之一。 discord.js.org/#/docs/main/stable/class/…
标签: discord discord.js bots