While waiting for this to get fixed, I found a workaround. By adding the presences intent all members will be cached. This allows us to use guild.members.cache. Just using .get() will however return undefined. If we use map like I’ve done in the example below, we get an array with all guild members.
I am already running the newest server artifact. So far I’ve tested build 5134, 5123 and 5104. The error persists on all these builds with the exact same error message.
Sure @nta . When testing OPs issue on the newest build (5134), I’m getting the same error: ‘refresh’ (NodeJS.Timeout.refresh()) is undefined in the FXServer Node.js “version” (Unsure what the correct term is). This leads to an error being thrown when i.e. using fetch() in discord.js version ^13.0.0.
Error message thrown on build 5134 using the code example OP provided:
Right, this library is a bit weird and somehow tries to get setTimeout from require('node:timers') yet somehow expects it to be equal to globalThis.clearTimeout etc. which in our runtime very much is not the case.
I guess you can ask the library’s maintainers to either consistently use globalThis.setTimeout etc. or add a require for clearTimeout too, but they’ve not been very receptive to this kind of request in the past.
You cannot use stock discord.js in fivem. it may look like you can and work like you can on the surface but if you actually log the debug event from it you will see it’s very much not happy as the timeout doesn’t clear and so the bot will loop reconnecting indefinitely every 20 seconds till it’s used up all your login allowance and discord sends you a message about suspicious activity and reset’s your token on you.
How do I know this? I maintain zdiscord and spent many weeks fighting it (and yes I just tested it again with the most recent artifacts and release of discord.js and it’s still the case)
Ah you’re right that was it. The code was just me trying to replicate what they were doing for the first handshake without all the overhead. I’ve had so many issues with the stupid timeout in their heartbeat from before with unref() and everything I just thought it was never going to work natively. My fork just doesn’t use the unrefs or node:timers at all and works fine now so I’ll just stick with that for now. They’re such a pain sometimes lol
Thanks for the reply, sorry for my ignorance <3
Seems to still be an issue using discord.js@13.6.0, running on Linux build 5375; the hello timeout is consistently triggered and never received - is there a recommended alternative version to use that this issue doesn’t exist on?
shard system opens a new fx server process and after 30 minutes the bot cannot receive any normal event ex: MessageCreate, GuildMemberAdd from what I tested it happens only when I open the bot through the fx server opening externally outside the fx server this does not occur, the same code