[英]discord.js "TypeError: fn is not a function"
So I started getting this "TypeError: fn is not a function" after I added the if-else statement to the code因此,在将 if-else 语句添加到代码中后,我开始收到此“TypeError:fn is not a function”
module.exports = {
name: `verify`,
description: "Verification part of bot",
execute (client, message, args){
let { channel, content, member } = message
let timeout;
const verified = message.guild.roles.cache.find(r => r.name === "Verified");
const notverified = message.guild.roles.cache.find(r => r.name === "Not Verified");
const rolemember = message.guild.roles.cache.find(r => r.name === "Member");
if(message.member.roles.cache.some(notverified)){
message.delete({timeout: 100})
message.member.roles.remove(notverified)
message.member.roles.add(verified)
message.member.roles.add(rolemember)
message.channel.send(`${member}You have been successfully verified!`);
message.channel.send(`Type to verify yourself!`);
} else {
message.delete({timeout: 100})
message.channel.send("You have already been verified!");
message.delete({timeout: 1000})
message.member.roles.add(role).catch(console.error);
}
}
};
Thats the code I have and my error is这就是我的代码,我的错误是
if (fn(val, key, this))
^
TypeError: fn is not a function
Thank you to anyone that is able to help me find a fix for this.感谢任何能够帮助我找到解决此问题的人。
It's because .some()
accepts a callback function only but notverified
is a Role or a falsy value.这是因为.some()
仅接受回调 function 但未notverified
是角色或虚假值。
Instead of .some()
, you could use .has()
to check if the user has the notverified
role:代替.some()
,您可以使用.has()
来检查用户是否具有未notverified
角色:
if(message.member.roles.cache.has(notverified.id)) {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.