简体   繁体   中英

TypeError: fn is not a function - but I didn't write fn in my file

I have no idea how this happened, I was just working on my code when all of a sudden, I get an error from another file. I didn't write fn anywhere in the file I was working in. The file I am working in is C:/Users/---/Discord Bot/index.js but I got the error from C:/Users/---/Discord Bot/node_modules/@discordjs/collection/dist/index.js - line 161 col 17 and I did see if(fn(val, key, this)) on that line but I changed NOTHING in that file, I didn't even know it existed before now. What do I do? Another npm install discord.js ? I only recently got it anyways. Here's the full error message in case you might need it.

    at Map.find (C:\Users\---\Discord Bot\node_modules\@discordjs\collection\dist\index.js:161:17)
    at Client.<anonymous> (C:\Users\---\Discord Bot\index.js:394:56)
    at Client.emit (node:events:381:22)
    at MessageCreateAction.handle (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:384:31)
    at WebSocketShard.onPacket (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:444:22)
    at WebSocketShard.onMessage (C:\Users\---\Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:301:10)
    at WebSocket.onMessage (C:\Users\---\Discord Bot\node_modules\ws\lib\event-target.js:132:16)
    at WebSocket.emit (node:events:369:20)

So re-installing discord.js won't help you. the fn on that line get's set by you on your index.js

For Example you perhaps run message.channel.find(VARIABLE) fn gets set to VARIABLE and then it tries to runs fn as a function even if VARIABLE isn't a function.

Now I do not know where fn get's set ( too lazy to check through the code ), but it does get set by you when you pass in a variable.

My guess is that it's on line 394 of YOUR index.js as that's when a chain of actions happen leading to fn being called.

This is about the best one can do without your code, and full error. You've given us the trace not the error. And without your code related to index.js#394 we can't help further.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM