[英]I'm having trouble with discord.js
i'm want add some permissions for using adminstator commands like ban, kick etc. When im add that commands i can't using kick command and when im tryna use ban command i get a output like that: "@xxx, you can't kick a member in this guild."我想添加一些使用管理员命令的权限,如禁令,踢等。当我添加这些命令时,我不能使用踢命令,当我尝试使用禁令命令时,我得到一个 output 像这样:“@xxx,你可以”不要踢这个公会的成员。”
if (message.author.bot) return;
// This is where we'll put our code.
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === 'kick') {
const user = message.guild.member(message.author);
if (user.hasPermission(['KICK_MEMBERS'])) {
let reason = args.join(" ");
const member = message.guild.member(etiketlenmiskisi);
message.channel.send(`${message.author} took her/his kickhammer!`);
message.channel.send('https://tenor.com/view/sao-liz-lisbeth-anime-ban-gif-14368031');
member.kick(reason);
message.channel.send(`${etiketlenmiskisi} kicked successfully.`);
}} else {
message.channel.send(`${message.author}, you can't kick a member in this guild.`);
}
});
client.on("message", message => {
if (message.author.bot) return;
// This is where we'll put our code.
if (message.content.indexOf(prefix) !== 0) return;
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
if(command === 'ban') {
const user = message.guild.member(message.author);
if (user.hasPermission(['BAN_MEMBERS'])) {
const etiketlenmiskisi = message.mentions.users.first();
let reason = args.join(" ");
const member = message.guild.member(etiketlenmiskisi);
message.channel.send(`${message.author} took her/his banhammer!`);
message.channel.send('https://tenor.com/view/sao-liz-lisbeth-anime-ban-gif-14368031');
member.ban(reason);
message.channel.send(`${etiketlenmiskisi} banned successfully.`);
}} else {
message.channel.send(`${message.author}, you can't ban a member in this guild.`);
}
});
It's in an else statement the "you can't kick".在 else 声明中,“你不能踢”。 It should be an else if.
它应该是一个 else if。 That should fix the problem.
那应该可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.