case 'mute':
var person = message.guild.member(message.mentions.users.first() || message.guild.roles.cache.find()(args[1]));
if(!person) return message.reply("That player doesn't exist!");
let mainrole = message.guild.roles.find(role => role.name === "Verified");
let role = message.guild.roles.find(role => role.name === "Mute");
if(!muterole) return message.reply("Couldn't find the mute role.");
let time = args[2];
if(!time){
return message.reply("Please didnt specify a time!");
}
person.roles.add(mainrole.id)
person.roles.remove(role.id);
message.channel.send(`@${person.user.tag} has now been muted for ${ms(ms(time))}`)
setTimeout(function(){
person.roles.add(mainrole.id)
person.roles.remove(role.id);
console.log(role.id)
message.channel.send(`@${person.user.tag} has been unmuted!`)
}, ms(time));
break;
}
});
is my code.
TypeError: fn is not a function at Client. (C:\Users\nippo\Desktop\aniGuesser\index.js:64:112) at Client.emit (events.js:327:22) at MessageCreateAction.handle (C:\Users\nippo\Desktop\aniGuesser\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\nippo\Desktop\aniGuesser\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) at WebSocketManager.handlePacket (C:\Users\nippo\Desktop\aniGuesser\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31) at WebSocketShard.onPacket (C:\Users\nippo\Desktop\aniGuesser\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22) at WebSocketShard.onMessage (C:\Users\nippo\Desktop\aniGuesser\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10) at WebSocket.onMessage (C:\Users\nippo\Desktop\aniGuesser\node_modules\ws\lib\event-target.js:125:16) at WebSocket.emit (events.js:315:20) PS C:\Users\nippo\Desktop\aniGuesser> node . aniGuesser Is Online. Bring the Cake! C:\Users\nippo\Desktop\aniGuesser\node_modules@discordjs\collection\dist\index.js:160 if (fn(val, key, this)) the error thingy.
I decided to start making a bot so my friends think im smart so i started watching a youtube series on how to configure these bots. In the process i decided to make a mute command cuz why not but then i got this error. before this i had "message.guild.roles.get" and the comments told me to change it to message.guild.roles.cache.find although that resolved my problem, i have this error now. btw even when i use the paste bin and only changing the words around it still has this error.
fn
that wasn't defined before. What does that look like? – Montgomery Wattsfn
as if it were a function. That would look something like thisfn()
, similar to what you're doing when you callconsole.log()
. The problem is coming from you callingfn
without it actually being a function. Isfn
defined earlier in your code? – Montgomery Wattsfn
came from. – cherryblossom