CreepPork / Apollo

Discord bot that allows to get status updates on your Arma 3 server.
MIT License
17 stars 8 forks source link

TypeError: Cannot read property 'guild' of null #153

Closed mackenziexD closed 3 years ago

mackenziexD commented 3 years ago
/root/xxx/dist/discord.js:224
        const roles = this.getAllRoles(member.guild.id);
                                              ^

TypeError: Cannot read property 'guild' of null
    at Discord.doesUserHaveServerManagerPermissions (/root/xxx/dist/discord.js:224:47)
    at Bot.refreshBotWithRolePermissions (/root/xxx/dist/bot.js:107:26)
    at Bot.onMessage (/root/xxx/dist/bot.js:61:22)
    at Client.<anonymous> (/root/xxx/dist/bot.js:51:59)
    at Client.emit (events.js:315:20)
    at Client.EventEmitter.emit (domain.js:483:12)
    at MessageCreateHandler.handle (/root/xxx/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/root/xxx/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (/root/xxx/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (/root/xxx/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
    at WebSocket.onMessage (/root/xxx/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:315:20)
    at WebSocket.EventEmitter.emit (domain.js:483:12)
    at Receiver.receiverOnMessage (/root/xxx/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:315:20)
    at Receiver.EventEmitter.emit (domain.js:483:12)
    at Receiver.dataMessage (/root/xxx/node_modules/ws/lib/receiver.js:422:14)
    at Receiver.getData (/root/xxx/node_modules/ws/lib/receiver.js:352:17)
    at Receiver.startLoop (/root/xxx/node_modules/ws/lib/receiver.js:138:22)
    at Receiver._write (/root/xxx/node_modules/ws/lib/receiver.js:74:10)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! apollo@2.2.0 start: `node .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the apollo@2.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-31T15_16_08_250Z-debug.log

bot has been running fine for a while but its now spitting errors when running any of these commands

CreepPork commented 3 years ago

Hmm, maybe Discord changed their API, I'll need to look into it.

CreepPork commented 3 years ago

Does the bot actually does what it is expected of it?

mackenziexD commented 3 years ago

2 seconds lemme load putty back up

mackenziexD commented 3 years ago
root@XXXX:~/XXX# npm run build

> apollo@2.2.0 build /root/XXX
> tsc -p tsconfig.json

root@XXXX:~/XXX# npm start

> apollo@2.2.0 start /root/XXX
> node .

Apollo is ready.
(node:714916) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at Object.Message (/root/XXX/node_modules/discord.js/src/util/Constants.js:188:23)
    at RESTMethods.getChannelMessage (/root/XXX/node_modules/discord.js/src/client/rest/RESTMethods.js:487:68)
    at TextChannel.fetchMessage (/root/XXX/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:201:37)
    at Discord.<anonymous> (/root/XXX/dist/discord.js:275:52)
    at Generator.next (<anonymous>)
    at /root/XXX/dist/discord.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/root/XXX/dist/discord.js:4:12)
    at Discord.addReactionToReactionMessage (/root/XXX/dist/discord.js:272:16)
    at Client.<anonymous> (/root/XXX/dist/discord.js:34:45)
    at Client.emit (events.js:327:22)
    at Client.EventEmitter.emit (domain.js:483:12)
    at WebSocketConnection.triggerReady (/root/XXX/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:125:17)
    at /root/XXX/node_modules/discord.js/src/client/websocket/packets/handlers/Ready.js:63:28
    at Timeout.<anonymous> (/root/XXX/node_modules/discord.js/src/client/Client.js:436:7)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7)
(node:714916) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:714916) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Failed to edit current message, id: 772111250204393476.
DiscordAPIError: Unknown Message
    at /root/XXX/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
    at /root/XXX/node_modules/snekfetch/src/index.js:215:21
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  path: '/api/v7/channels/663195301204459540/messages/772111250204393476',
  code: 10008,
  method: 'GET'

on a fresh install with no commands being ran it also does not create the embed for the server

bot starts but the bot status is "bot failed" the bot types in the channel set in env. but thats about it

mackenziexD commented 3 years ago

bot was running the old settings.json for some reason hence the api error

bot creates the embed as expected but throws errors when any commands are used

/root/XXX/dist/discord.js:224
        const roles = this.getAllRoles(member.guild.id);
                                              ^

TypeError: Cannot read property 'guild' of null
    at Discord.doesUserHaveServerManagerPermissions (/root/XXX/dist/discord.js:224:47)
    at Bot.refreshBotWithRolePermissions (/root/XXX/dist/bot.js:107:26)
    at Bot.onMessage (/root/XXX/dist/bot.js:61:22)
    at Client.<anonymous> (/root/XXX/dist/bot.js:51:59)
    at Client.emit (events.js:315:20)
    at Client.EventEmitter.emit (domain.js:483:12)
    at MessageCreateHandler.handle (/root/XXX/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/root/XXX/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (/root/XXX/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (/root/XXX/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:296:17)
    at WebSocket.onMessage (/root/XXX/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:315:20)
    at WebSocket.EventEmitter.emit (domain.js:483:12)
    at Receiver.receiverOnMessage (/root/XXX/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:315:20)
    at Receiver.EventEmitter.emit (domain.js:483:12)
    at Receiver.dataMessage (/root/XXX/node_modules/ws/lib/receiver.js:422:14)
    at Receiver.getData (/root/XXX/node_modules/ws/lib/receiver.js:352:17)
    at Receiver.startLoop (/root/XXX/node_modules/ws/lib/receiver.js:138:22)
    at Receiver._write (/root/XXX/node_modules/ws/lib/receiver.js:74:10)
    at doWrite (_stream_writable.js:403:12)
    at writeOrBuffer (_stream_writable.js:387:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! apollo@2.2.0 start: `node .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the apollo@2.2.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-10-31T15_44_23_164Z-debug.log

discord.js:224 const roles = this.getAllRoles(member.guild.id); being the main its not liking

CreepPork commented 3 years ago

Our bot installation works fine, it more seems that someone might have adjusted the permissions of the bot in the server itself or the Developer portal. The message member property, I am assuming, is undefined, that's why it's returning where .guild as of null.

That might mean that either there's some issue with the configuration of Apollo or it doesn't have enough permissions.

mackenziexD commented 3 years ago
IP=XXX
DISPLAY_IP=XXX
PORT=XXX

COLOR_OK=3779158
COLOR_ERROR=14370117
COLOR_MAINTENANCE=2526162

LOCALE=en

REFRESH_COMMAND=!update
REFRESH_FORCE_COMMAND=!updateForce
LIMIT_REFRESH_FORCE_TO_MANAGER=true
REPLY_DM_ON_NO_PERMS=true

MAINTENANCE_TOGGLE_COMMAND=!maintenanceMode

REACTION_MESSAGE_ID=
REACTION_ROLE_ID=
REACTION_EMOJI=🚨
MINIMUM_PLAYER_COUNT_FOR_PING=6
TIMEOUT_BETWEEN_PLAYER_PINGS_IN_MINUTES=40

CHANNEL_ID=663195301204459540
SERVER_MANAGER_ROLE_ID=635055704608342021

TIME_TO_CHECK_MINUTES=5

MAXIMUM_REFRESH_FAILURES=3

SENTRY_DSN=

SECRET=XXXXXXXXXX

bot has admin so its not that, config hasnt changed.

what version of discord.js are you using

CreepPork commented 3 years ago

Try to add the reaction message info too.

mackenziexD commented 3 years ago

Try to add the reaction message info too.

even with the reaction info added the bot still crashes on running commands for the same thing

/root/xxx/dist/discord.js:224
const roles = this.getAllRoles(member.guild.id);
                                        ^
TypeError: Cannot read property 'guild' of null
CreepPork commented 3 years ago

Can you try to create a new Discord server and try the bot there? If it doesn't work, try recreating the Secret in the Developer portal.

BroBeansCPG commented 3 years ago

I'm getting a similar error,

Fresh install & server got it to display the embed but won't react to commands

mackenziexD commented 3 years ago

I'm getting a similar error,

Fresh install & server got it to display the embed but won't react to commands

same for me

CreepPork commented 3 years ago

Yeah, it looks like something is borked. I think that Discord changed their API a bit and that has now broken Apollo. We have the errors on our two bots too but Apollo still processes the commands.

I'll look into the issue once I have the time.

CreepPork commented 3 years ago

The issue is now fixed, please see #154 as an upgrade guide.