Rare Error

[ERROR] Encountered error on event listener "messageUpdate" for event "messageUpdate" at path "/home/container/src/listeners/messageUpdate.js" TypeError: Cannot read properties of null (reading 'permissions')
at isStaff (/home/container/src/utils.js:621:17)
at automod (/home/container/src/handlers/automod.js:4:48)
at MessageUpdate.run (/home/container/src/listeners/messageUpdate.js:8:12)
at /home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:63
at Object.fromAsync (/home/container/node_modules/@sapphire/result/dist/cjs/index.cjs:619:46)
at MessageUpdate._run (/home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:42)
at Client.emit (node:events:518:28)
at module.exports [as MESSAGE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_UPDATE.js:14:12)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
[ERROR] Encountered error on event listener "messageUpdate" for event "messageUpdate" at path "/home/container/src/listeners/messageUpdate.js" TypeError: Cannot read properties of null (reading 'permissions')
at isStaff (/home/container/src/utils.js:621:17)
at automod (/home/container/src/handlers/automod.js:4:48)
at MessageUpdate.run (/home/container/src/listeners/messageUpdate.js:8:12)
at /home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:63
at Object.fromAsync (/home/container/node_modules/@sapphire/result/dist/cjs/index.cjs:619:46)
at MessageUpdate._run (/home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:42)
at Client.emit (node:events:518:28)
at module.exports [as MESSAGE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_UPDATE.js:14:12)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
i entered into my main bot's console and this error was logged, I tried reproducing the error but I couldn't, everything was working fine, my best guess is that for some reason <Message>.member went undefined, any ideas?
15 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
-Carlos👑
-Carlos👑OP10mo ago
Also some time ago I had this error, which was fixed by adding a ? so it looks something like this message.author?.bot
[ERROR] Encountered error on event listener "messageUpdate" for event "messageUpdate" at path "/home/container/src/listeners/messageUpdate.js" TypeError: Cannot read properties of null (reading 'bot')
at automod (/home/container/src/handlers/automod.js:4:40)
at MessageUpdate.run (/home/container/src/listeners/messageUpdate.js:8:12)
at /home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:63
at Object.fromAsync (/home/container/node_modules/@sapphire/result/dist/cjs/index.cjs:619:46)
at MessageUpdate._run (/home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:42)
at Client.emit (node:events:518:28)
at module.exports [as MESSAGE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_UPDATE.js:14:12)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:282:31)
[ERROR] Encountered error on event listener "messageUpdate" for event "messageUpdate" at path "/home/container/src/listeners/messageUpdate.js" TypeError: Cannot read properties of null (reading 'bot')
at automod (/home/container/src/handlers/automod.js:4:40)
at MessageUpdate.run (/home/container/src/listeners/messageUpdate.js:8:12)
at /home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:63
at Object.fromAsync (/home/container/node_modules/@sapphire/result/dist/cjs/index.cjs:619:46)
at MessageUpdate._run (/home/container/node_modules/@sapphire/framework/dist/cjs/lib/structures/Listener.cjs:27:42)
at Client.emit (node:events:518:28)
at module.exports [as MESSAGE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_UPDATE.js:14:12)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.cjs:282:31)
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
-Carlos👑
-Carlos👑OP10mo ago
I tried recreating it as well, but no luck yeah obviously
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
-Carlos👑
-Carlos👑OP10mo ago
could it be a host issue? i keep trying to recreate it on the testing bot but no errors are logged
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Squid
Squid10mo ago
the error says the member is null, not undefined the member can be missing whenever the message is sent outside of a server
-Carlos👑
-Carlos👑OP10mo ago
i have an !message.guild check yeah its defined I haven't been able to recreate it, the errors just appear randomly
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
-Carlos👑
-Carlos👑OP10mo ago
as a Message object also these random errors only happen in the main bot, have been trying to recreate them on the testing bot but no luck and before someone asks, yes they both have the same code this error was fixed by adding a optional chain, my best guess is that for some reason <Message>.author went null I have also tried to recreate them in the main bot, but no luck aswell
Squid
Squid10mo ago
the author can be null if the updated message was not originally cached Are you checking the old member or the new member? Unless you explicitly need the old member's permissions, you should try and use the new data as much as possible something something, "partials" behavior
-Carlos👑
-Carlos👑OP10mo ago
wdym? the isStaff function is from the automod, not message log i have a if check for that here's my partials: partials: [Partials.Message, Partials.Channel],
Squid
Squid10mo ago
I know, but you're passing in one of the <Message>.member instances to isStaff() so you should prioritize newMessage.member rather than oldMesasge.member if possible
-Carlos👑
-Carlos👑OP10mo ago
im not using isStaff anywhere on the message log I will change my if check on the automod file from if (!message.guild || message.author?.bot || isStaff(message.member)) return; to if (!message?.member || message.author.bot || isStaff(message.member)) return; to hopefully fix these errors as I said i cannot reproduce these errors so i will need to wait a few days to see if they appear on console newMsg i just implemented this in the main bot, will come back if the errors appear again
Want results from more Discord servers?
Add your server