Sammy
Sammy
DIAdiscord.js - Imagine an app
Created by Sammy on 5/1/2024 in #djs-questions
@discordjs/brokers timeout when not using reply()
I'm using the @discordjs/brokers package. Specifically the Redis streams broker. In emitted events you get these ack and reply functions. I am aware of ack and it's need, however reply doesn't seem useful to me. I guess it could be used to inform the publisher that the event was received, but I'd prefer to not send 2 calls over redis for every event (publish and reply). However, when I just simply don't use the reply() function, I get a timeout 5 seconds later from the caller, which apparently is expecting a reply
88 replies
DIAdiscord.js - Imagine an app
Created by Sammy on 4/30/2024 in #djs-questions
Resuming with cached data using @discordjs/ws
Could anyone guide me in the right direction for doing my own resumes with @discordjs/ws? I would like to get my shards in a state where the worker processes have been spawned, and the gateway connection are made, but without an identify being sent. I am attempting to cache my resume data so that with a restart of my ws process, I can resume. I tried using the following 2 lines of code:
await manager.updateShardCount(shardCount);
await strategy.spawn([...Array(shardCount).keys()]);
await manager.updateShardCount(shardCount);
await strategy.spawn([...Array(shardCount).keys()]);
to get my shards to be spawned, however doing a manager.send() after this, still results in the following error:
Error: WebSocketShard wasn't connected
at WebSocketShard.send (file:///prod/gateway/node_modules/.pnpm/@[email protected][email protected]/node_modules/@discordjs/ws/dist/index.mjs:745:13)
at MessagePort.<anonymous> (file:///prod/gateway/node_modules/.pnpm/@[email protected][email protected]/node_modules/@discordjs/ws/dist/index.mjs:1251:23)
Error: WebSocketShard wasn't connected
at WebSocketShard.send (file:///prod/gateway/node_modules/.pnpm/@[email protected][email protected]/node_modules/@discordjs/ws/dist/index.mjs:745:13)
at MessagePort.<anonymous> (file:///prod/gateway/node_modules/.pnpm/@[email protected][email protected]/node_modules/@discordjs/ws/dist/index.mjs:1251:23)
I'm not sure if maybe I also need some additional code on the worker/manager side to support resuming myself? I assumed not but any more info would be appreciated
4 replies
DIAdiscord.js - Imagine an app
Created by Sammy on 3/9/2023 in #djs-questions
Issue with using a proxy
When running a slash command, I've observed an error at the following line: await interaction.deferReply({ephemeral}); Error:
TypeError: Cannot read properties of null (reading 'startsWith')
at parseResponse (/node_modules/discord.js/src/rest/RequestHandler.js:14:38)
at RequestHandler.execute (/node_modules/discord.js/src/rest/RequestHandler.js:302:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async CommandInteraction.deferReply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:61:5)
at Object.run (/src/commandsSlash/miscellaneous/ping.ts:22:9)
at Client.interactionCreate (/src/events/interactionCreate.ts:80:17)
TypeError: Cannot read properties of null (reading 'startsWith')
at parseResponse (/node_modules/discord.js/src/rest/RequestHandler.js:14:38)
at RequestHandler.execute (/node_modules/discord.js/src/rest/RequestHandler.js:302:14)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/node_modules/discord.js/src/rest/RequestHandler.js:51:14)
at async CommandInteraction.deferReply (/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:61:5)
at Object.run (/src/commandsSlash/miscellaneous/ping.ts:22:9)
at Client.interactionCreate (/src/events/interactionCreate.ts:80:17)
I'm proxying all discord requests through a proxy and I have 2 proxies available, one works, one doesn't. The differences between the two are: Working proxy: HTTP only, not HTTPS (Slightly modified djs for this to allow http proxies to work) direct ip:port -> proxy Failing proxy: Forced HTTPS + HSTS (Modifications removed as https proxies are supported out of the box) Domain name -> Cloudflare (+ WAF) -> nginx -> proxy Normal commands work perfectly fine, this error only occurs on interaction.deferReply() and probably other interaction related requests as well, however I havent tested that aside from deferReply
13 replies
DIAdiscord.js - Imagine an app
Created by Sammy on 10/7/2022 in #djs-questions
[ws] Receiving guilds is not consistent
I'm currently noticing that about half the time I only receive dispatches for 1 out of 2 guilds my bot is in (small testing servers). I always get a ready payload with a list of 2 expected guilds, however i only receive one of them regularly (Always the same one too). This happens even with no code changes, simply restarting the gateway shows this behaviour. package: @discordjs/ws 0.3.0 Also happens on latest dev: @discordjs/ws 0.3.1-dev.1665144455-9f68d73.0
3 replies
DIAdiscord.js - Imagine an app
Created by Sammy on 10/7/2022 in #djs-questions
[ws] Accessing list of unavailable guilds when shard turns ready
In @discordjs/ws, how am i supposed to access the list of unavailable guilds after a shard becomes ready? The ready event on WebSocketShard is hidden away and the ready even on WebSocketManager doesnt supply me with the data i want. The reason i want the list of unavailable guilds is so that i can use these when receiving GUILD_CREATEs to know whether something is a new guild or simply a guild becoming available
6 replies