So I started getting this "TypeError: fn is not a function" after I added the if-else statement to the code
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.
CodePudding user response:
It's because .some()
accepts a callback function only but notverified
is a Role or a falsy value.
Instead of .some()
, you could use .has()
to check if the user has the notverified
role:
if(message.member.roles.cache.has(notverified.id)) {}