destruc7i0n / shulker

A Discord to Vanilla Minecraft Chat Gateway
ISC License
135 stars 47 forks source link

"Cannot read property 'id' of undefined" #73

Closed DragaputCataput closed 2 years ago

DragaputCataput commented 3 years ago

yarn run v1.22.10
$ node build/index.js
[INFO] Using configuration file: ../config.json
[INFO] Using Discord WebHooks to send messages
C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\ClientDataManager.js:81
        guild.channels.set(channel.id, channel);
                                   ^

TypeError: Cannot read property 'id' of undefined
    at ClientDataManager.newChannel (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\ClientDataManager.js:81:36)
    at Guild.setup (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\structures\Guild.js:206:68)
    at GuildCreateHandler.handle (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:12:15)
    at WebSocketPacketManager.handle (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:105:65)
    at WebSocketConnection.onPacket (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
    at WebSocketConnection.onMessage (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
    at WebSocket.onMessage (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:314:20)
    at Receiver.receiverOnMessage (C:\Users\Xport\Downloads\shulker-3.0.0\shulker-3.0.0\node_modules\ws\lib\websocket.js:789:20)
    at Receiver.emit (events.js:314:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
destruc7i0n commented 3 years ago

Not sure exactly what the problem is here. What does your config look like (removing any sensitive data)? Is your bot setup correclty?

speakwithanimals commented 2 years ago

I just had the same issue. It happened after I tried to add a server image at "SERVER_IMAGE": "smithhappy.png", at least I think. I'll update if I get it working again

config.json: `{ "PORT": 8000,

"USE_WEBHOOKS": true,
"WEBHOOK_URL": "xxx",
"IGNORE_WEBHOOKS": true,
"DISCORD_TOKEN": "xxx",
"DISCORD_CHANNEL_ID": "xxx",
"DISCORD_CHANNEL_NAME": "#mc-chat",
"DISCORD_MESSAGE_TEMPLATE": "`%username%`: %message%",

"MINECRAFT_SERVER_RCON_IP": "127.0.0.1",
"MINECRAFT_SERVER_RCON_PORT": 25575,
"MINECRAFT_SERVER_RCON_PASSWORD": "xxx",
"MINECRAFT_TELLRAW_TEMPLATE": "[{\"color\": \"#55ffff\", \"text\": \"<%username%> %message%\"}]",
"MINECRAFT_TELLRAW_DOESNT_EXIST": false,
"MINECRAFT_TELLRAW_DOESNT_EXIST_SAY_TEMPLATE": "<%username%> %message%",

"IS_LOCAL_FILE": true,
"LOCAL_FILE_PATH": "E:/Games/Minecraft/2022 server/logs/latest.log",

"SHOW_INIT_MESSAGE": true,

"ALLOW_USER_MENTIONS": true,
"ALLOW_HERE_EVERYONE_MENTIONS": false,
"ALLOW_SLASH_COMMANDS": true,
"SLASH_COMMAND_ROLES": ["op"],

"WEBHOOK": "/minecraft/hook",
"REGEX_SERVER_PREFIX": "\\[Server thread/INFO\\]:",
"REGEX_MATCH_CHAT_MC": "^<([^>]*)> (.*)",
"REGEX_IGNORED_CHAT": "packets too frequently", 
"DEBUG": false,

"SERVER_NAME": "Agent_Smith",
"SERVER_IMAGE": "smithhappy.png",
"SHOW_SERVER_STATUS": true,
"SHOW_PLAYER_CONN_STAT": true,
"SHOW_PLAYER_ADVANCEMENT": true,
"SHOW_PLAYER_DEATH": true,
"SHOW_PLAYER_ME": true,
"DEATH_KEY_WORDS": ["shot", "fell", "death", "died", "doomed", "pummeled", "removed", "didn't want", "withered", "squashed", "flames", "burnt", "walked into", "bang", "roasted", "squished", "drowned", "killed", "slain", "blown", "blew", "suffocated", "struck", "lava", "impaled", "speared", "fireballed", "finished", "kinetic"]

} `

cmd log:

shulker@3.0.0 start E:\Games\Minecraft\2022 server\shulker-master node build/index.js

[INFO] Using configuration file: ../config.json [INFO] Using Discord WebHooks to send messages E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\client\ClientDataManager.js:81 guild.channels.set(channel.id, channel); ^

TypeError: Cannot read property 'id' of undefined at ClientDataManager.newChannel (E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\client\ClientDataManager.js:81:36) at Guild.setup (E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\structures\Guild.js:307:68) at GuildCreateHandler.handle (E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\client\websocket\packets\handlers\GuildCreate.js:12:15) at WebSocketPacketManager.handle (E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:108:65) at WebSocketConnection.onPacket (E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:336:35) at WebSocketConnection.onMessage (E:\Games\Minecraft\2022 server\shulker-master\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:299:17) at WebSocket.onMessage (E:\Games\Minecraft\2022 server\shulker-master\node_modules\ws\lib\event-target.js:120:16) at WebSocket.emit (events.js:315:20) at Receiver.receiverOnMessage (E:\Games\Minecraft\2022 server\shulker-master\node_modules\ws\lib\websocket.js:789:20) at Receiver.emit (events.js:315:20) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! shulker@3.0.0 start: node build/index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the shulker@3.0.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! C:\Users\josep\AppData\Roaming\npm-cache_logs\2021-11-30T20_47_58_731Z-debug.log

speakwithanimals commented 2 years ago

sidenote, I'm not familiar at all with java but I'm running the most recent version of Adoptium. I attached the debug log 2021-11-30T20_59_20_057Z-debug.log .

speakwithanimals commented 2 years ago

tried removing all of the related files and going through all of the setup steps again, still getting the same issue :/

destruc7i0n commented 2 years ago

What channel type is it? I feel like Discord may of updated this https://github.com/discordjs/discord.js/blob/v11/src/client/ClientDataManager.js#L63-L79

speakwithanimals commented 2 years ago

It's a text channel. What's strange is I had it set up exactly the same on my feature test discord and it was working great, but I just realized this actually started when I invited the bot to the server on which I intend to use it. Since then even removing all the files related to the bot and running those npm commands again causes the same error. I'll double check the settings this afternoon and run everything again just to be sure!

destruc7i0n commented 2 years ago

@speakwithanimals I just pushed a couple of updates (https://github.com/destruc7i0n/shulker/commit/527ba4df2211f8787a4ccee707861dd0959eae37) including a check for the channel on launch, can you try again with these changes?

speakwithanimals commented 2 years ago

same error unfortunately :/ 2021-12-08T17_43_39_748Z-debug.log

my config.json (with bot info redacted) `{ "PORT": 8000,

"USE_WEBHOOKS": true, "WEBHOOK_URL": "xxx", "IGNORE_WEBHOOKS": true, "DISCORD_TOKEN": "xxx", "DISCORD_CHANNEL_ID": "xxx", "DISCORD_CHANNEL_NAME": "#server-chat", "DISCORD_MESSAGE_TEMPLATE": "%username%: %message%",

"MINECRAFT_SERVER_RCON_IP": "127.0.0.1", "MINECRAFT_SERVER_RCON_PORT": 25575, "MINECRAFT_SERVER_RCON_PASSWORD": "xxx", "MINECRAFT_TELLRAW_TEMPLATE": "[{\"color\": \"white\", \"text\": \"<%username%> %message%\"}]", "MINECRAFT_TELLRAW_DOESNT_EXIST": false, "MINECRAFT_TELLRAW_DOESNT_EXIST_SAY_TEMPLATE": "<%username%> %message%",

"IS_LOCAL_FILE": true, "LOCAL_FILE_PATH": "E:/Games/Minecraft/2022 server/logs/latest.log",

"SHOW_INIT_MESSAGE": true,

"ALLOW_USER_MENTIONS": true, "ALLOW_HERE_EVERYONE_MENTIONS": false, "ALLOW_SLASH_COMMANDS": true, "SLASH_COMMAND_ROLES": ["op"],

"WEBHOOK": "/minecraft/hook", "REGEX_SERVER_PREFIX": "\[Server thread/INFO\]:", "REGEX_MATCH_CHAT_MC": "^<([^>])> (.)", "REGEX_IGNORED_CHAT": "packets too frequently", "DEBUG": false,

"SERVER_NAME": "Agent Smith", "SERVER_IMAGE": "", "HEAD_IMAGE_URL": "https://mc-heads.net/avatar/%uuid%/256", "DEFAULT_PLAYER_HEAD": "c06f89064c8a49119c29ea1dbd1aab82", "SHOW_SERVER_STATUS": false, "SHOW_PLAYER_CONN_STAT": false, "SHOW_PLAYER_ADVANCEMENT": false, "SHOW_PLAYER_DEATH": false, "SHOW_PLAYER_ME": false, "DEATH_KEY_WORDS": [ "shot", "fell", "death", "died", "doomed", "pummeled", "removed", "didn't want", "withered", "squashed", "flames", "burnt", "walked into", "bang", "roasted", "squished", "drowned", "killed", "slain", "blown", "blew", "suffocated", "struck", "lava", "impaled", "speared", "fireballed", "finished", "kinetic" ] }`

destruc7i0n commented 2 years ago

@speakwithanimals Thanks for testing it and letting me know!

I did some digging and it seems to be because of a stage channel and the version of discord.js I was using not supporting it. I've updated discord.js to the latest version which should hopefully fix this. Can you try the bot from this branch with the update to discord.js? https://github.com/destruc7i0n/shulker/tree/discord-js-13

speakwithanimals commented 2 years ago

I must be cursed or something, haha. I tried two separate channels and I'm getting what looks like the same issue in both.

2021-12-20T03_29_51_456Z-debug.log 2021-12-20T03_32_22_577Z-debug.log 2021-12-20T03_33_23_029Z-debug.log config redacted.txt

.

destruc7i0n commented 2 years ago

@speakwithanimals would you mind sending the output of the script itself rather than the debug log? The debug log is just about the same in all three files there

speakwithanimals commented 2 years ago

I don't know why, but I just assumed I wouldn't be able to understand the output myself, so after taking a look at it I realized I just needed to update Node! Sorry about the confusion 🙃 It's working great now!

destruc7i0n commented 2 years ago

@speakwithanimals That is great to hear, thanks for helping me debug this nonetheless. Happy holidays!

destruc7i0n commented 2 years ago

Fixed in #77