Issue
I have a question about the discord boot on Debian9, I'm trying to run my code, but VPS throws me this error. Previously, I had this bot normally on another VPS and everything worked as it should, but now it doesn't work. I don't know if I'm missing any modules or badly installed node and npm.
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
at MessageEmbed.addFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:259:42)
at Client.client.on (/home/bot/main.js:368:22)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
at MessageEmbed.addFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:259:42)
at Client.client.on (/home/bot/main.js:201:14)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
ReferenceError: guildMember is not defined
at Client.client.on (/home/bot/main.js:446:9)
at Client.emit (events.js:198:13)
at Object.module.exports [as GUILD_MEMBER_UPDATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js:18:16)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/home/bot/node_modules/ws/lib/websocket.js:835:20)
at Receiver.emit (events.js:198:13)
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
at MessageEmbed.addFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:259:42)
at Client.client.on (/home/bot/main.js:368:22)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8)
at MessageEmbed.addFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:259:42)
at Client.client.on (/home/bot/main.js:368:22)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:450:8)
at MessageEmbed.addFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:266:42)
at Client.client.on (/home/bot/main.js:368:22)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
ReferenceError: guildMember is not defined
at Client.client.on (/home/bot/main.js:446:9)
at Client.emit (events.js:198:13)
at GuildMemberUpdateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/GuildMemberUpdate.js:30:51)
at Object.module.exports [as GUILD_MEMBER_UPDATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js:4:36)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/home/bot/node_modules/ws/lib/websocket.js:825:20)
TypeError: fields.flat is not a function
at Function.normalizeFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:450:8)
at MessageEmbed.addFields (/home/bot/node_modules/discord.js/src/structures/MessageEmbed.js:266:42)
at Client.client.on (/home/bot/main.js:368:22)
at Client.emit (events.js:198:13)
at MessageCreateAction.handle (/home/bot/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/home/bot/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:384:31)
at WebSocketShard.onPacket (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
at WebSocketShard.onMessage (/home/bot/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
at WebSocket.onMessage (/home/bot/node_modules/ws/lib/event-target.js:132:16)
I don't know what to do with it, am I missing a module installed?
Solution
The .flat()
method is only available in Node version 11 and later, and discord.js v12 requires Node 12.x or higher. Make sure you're using the latest version. Read more about it on the guide.
Answered By - Zsolt Meszaros Answer Checked By - Senaida (WPSolving Volunteer)