gpt4 book ai didi

javascript - discord.js 未处理的PromiseRejectionWarning : TypeError: Cannot read property 'kickable' of undefined

转载 作者:行者123 更新时间:2023-12-02 21:09:57 30 4
gpt4 key购买 nike

昨天我可以运行这个票据。今天我收到错误

(节点:29568)UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“kickable”

我正在运行版本“discord.js”:12.1.1 - 我希望有人能发现我在这里做错了什么......因为它让我发疯。

下面你可以找到我的 kickuser.js - 脚本 + 我的 index.js 脚本 -> https://pastebin.com/7tLkuU5p

const Discord = require("discord.js");

module.exports.run = async (bot, message, args) => {

if (message.member.hasPermission("KICK_MEMBERS")) {

if (!message.mentions.users) return message.reply('You must tag 1 user.');

else {

const channel = message.guild.channels.cache.get(696692048543088691);
const member = message.mentions.members.first();
let reason = message.content.split(" ").slice(2).join(' ');

if (member.kickable == false) return message.channel.send("That user cannot be kicked!")

else {

if (!reason) reason = (`No reason provided.`);

await member.send(`You have been kicked from **${message.guild.name}** with the reason: **${reason}**`)
.catch(err => message.channel.send(`⚠ Unable to contact **${member}**.`));

await member.kick(reason);

const kickEmbed = new MessageEmbed()
.setAuthor(member.user.tag, member.user())
.setThumbnail(member.user.avatarURL())
.setColor("#ee0000")
.setTimestamp()
.addField("Kicked By", message.author.tag)
.addField("Reason", reason);

await channel.send(kickEmbed);

console.log(`${message.author.tag} kicked ${member.user.tag} from '${message.guild.name}' with the reason: '${reason}'.`);

}
}
} else {
message.channel.send("You do not have permission to use kick.");
return;
}
}


module.exports.help = {
name: "kickuser"
}

我希望有人能帮助我。提前致谢。

最佳答案

message.mentions.users 始终评估为 true,因为它是一个对象,要检查消息是否有任何提及,您可以执行以下操作:

    if(!message.mentions.members.first()) return message.reply('You must tag 1 user.');

而不是:

    if(!message.mentions.users) ...

关于javascript - discord.js 未处理的PromiseRejectionWarning : TypeError: Cannot read property 'kickable' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61125059/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com