ElJay
ElJay
DIAdiscord.js - Imagine an app
Created by ElJay on 4/8/2025 in #djs-questions
How to create a rest-only (no gateway) application?
I can find tons of documentation and guides on handling interactions via the gateway, but I can't find any documentation on using discord.js to make a REST only application that replies to interactions without a gateway connection. Does discord.js not provide any functionality for that use case?
3 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 4/5/2025 in #djs-questions
Best way to check for mutual servers with a user?
I want to know if a user has any mutual servers with the bot, I don't care about how many just whether there are any or not. I have two ideas but really don't like them: - Maintain a cache of all guild members and check the cache. - Fetch the user from every guild and check for a 10007 (unknown member) error. The only use for a guild member cache would be checking for mutual servers so it's hard to justify all of that memory usage, and doing so also requires a new privileged intent that I don't otherwise need. And fetching will either spam the API until I get IP banned or take unreasonably long to go through every guild one-by-one, I see no way to check every guild individually in a reasonable way. Is there really no better way to do this?
3 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 3/17/2025 in #djs-questions
Which errors does discord.js handle and which does it let bubble up?
To give one example, it looks like discord.js handles NotAuthenticated and unexpected close codes but not DisallowedIntents. But I wouldn't have known that if I didn't dig through the source code. And that's just websocket close codes, what about REST errors or errors that come from discord but aren't explicitly part of the API (e.g. codes like 1001)? Is there proper documentation on this anywhere?
128 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/23/2024 in #djs-questions
How to run recommended ("auto") shard count all in one thread?
As far as I can tell, the shard manager is always either multi-process or multi-threaded. But I can't find any other way to run multiple shards, so I'm not sure how to do that in a single thread.
8 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/21/2024 in #djs-questions
Does the REST handler retry failed requests?
See title. I'm mainly referring to errors with a 5xx code, but I do want to know if the REST handler retries any requests of any type. I want to handle those errors and would like to know if I'm just repeating error handling logic that discord.js already performs. And if there are community resources or examples on how best to implement this please point me to them, I wasn't able to find anything when I looked.
26 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/19/2024 in #djs-questions
How to respond negatively to an autocomplete interaction?
Discord's documentation really doesn't make this clear unless I'm missing something... Should I interaction.respond() with an empty array? Or just not respond at all? Or respond in some other way?
3 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/19/2024 in #djs-questions
How to check whether a user can be DMed?
See title. The best I can figure out is actually trying to send a DM, but by the point I'm doing that there's nothing I can do if it fails, so it would be nice if there's a better way to check.
8 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/11/2024 in #djs-questions
Strange session error when logging in.
This error is being thrown when I call client.login(token):
Not enough sessions remaining to spawn 1 shards; only 0 remaining
Any idea what's causing this?
6 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/8/2024 in #djs-questions
Token is correct but still getting "Invalid Authorization Header"
See title. I'm trying to client.login(token) and I've tried both "Bot TOKEN" and "TOKEN", both give the same error.
4 replies
DIAdiscord.js - Imagine an app
Created by ElJay on 10/5/2024 in #djs-questions
Can discord.js store snowflakes as bigints instead of strings?
See title, I couldn't spot any options for it in the docs and I'm curious if it's possible.
4 replies