sludge
DIAdiscord.js - Imagine a bot
•Created by sludge on 4/7/2023 in #djs-questions
Can't get started with @discordjs/core
Decided to mess around with
/core
today to see if it might be useful for a small lightweight project I'm planning.
Following the example on GitHub gets me nowhere and just presents an error I don't fully understand.
This is using the example provided here: https://github.com/discordjs/discord.js/tree/main/packages/core
The only alteration I have made is actually defining the token.13 replies
DIAdiscord.js - Imagine a bot
•Created by sludge on 3/16/2023 in #djs-questions
ShardingManager Woes
So my main project is still growing and I'm by no means at a point where sharding is required, but I'm also not one to put off something that I know will be a headache later on.
With that in mind I have implemented a sharding setup in my application now following the official guide. My application works and starts and given the lower guild count, only one shard gets spawned (shard 0). I've done this following many comments from people advising there is no harm in having it setup now to save me work later on.
My issue comes from the fact that no matter what I do, the
shard
property on client is always null even though I know the client was started within a shard.
This means I'm unable to use any of the shard utilities like broadcastEval
and fetchClientValues
for instance.
I've asked for general help regarding this in #djs-help-v14 but I'm hoping with it's own thread here, someone might have more insight on what I could be doing wrong.
Disclosure: I'm using DJS Dev at the moment, but I've been having this same behaviour with 14.7.1 and also now 14.8.0 as well.
DJS: [email protected]
Node: 19.3.053 replies
DIAdiscord.js - Imagine a bot
•Created by sludge on 2/18/2023 in #djs-questions
Discord.JS ShardingManager and Fastify
One of my Discord applications is growing at a good rate and it's getting to a point where I'm going to need to start messing around with sharding.
My issue is that part of the application is the use of a Fastify server that listens for a few custom requests - one in particular being for the interactions endpoint URL (I use a sort of proxy server to still give a response when the application is offline for maintenance etc).
I'm confused about the logic of how the application needs to work going forward while taking the Fastify server in to account. I'm fairly certain that as soon as a second shard comes online, it's going to fail to start Fastify because the port will already be in use on the first shard. This being that I have the Fastify instance as a 'property' of the client.
Am I right in thinking that I should perhaps instead move that part of my application on to the ShardingManager and have one parent instance of Fastify to handle all of the shards? Should I expect a huge performance hit by having to lookup what guild an interaction was run on, to then forward the interaction from the parent Fastify instance down to the correct shard?
It's a lot of work for someone like me so hoping for some advice first before I spend hours/days rewriting large sections of the application.
5 replies
DIAdiscord.js - Imagine a bot
•Created by sludge on 1/27/2023 in #djs-questions
Using raw APIInteraction data with DJS
I am no doubt going to sound like a moron with this question and perhaps it's not even something relevant to this Discord.
But here it goes.
I want to build a sort of proxy for interactions on one of my applications. A webhook server if you want to call it that. So far I have the proxy side working as intended; the endpoint URL is set in the dev portal, that sends application commands to the webhook server which then in turn forwards the request body to a Fastify listener on the Discord application side as an APIInteraction.
Now, without needing to rewrite the entire logic of my extensive
interactionCreate
listeners, I figured a "hacky" workaround would be to use client.emit('interactionCreate', interaction)
with interaction
being the APIInteraction data. Obviously this doesn't work though as the gateway event in DJS expects Interaction<CacheType>
.
I will admit I don't understand the backend code of DJS enough to work this out on my own but I'm curious if it's possible for me to somehow put that APIInteraction in to DJS to get back out the type it expects complete with the DJS methods and properties I need (things like isChatInputCommand, isButton, etc)
PS. please don't flame me if I'm being stupid 16 replies
DIAdiscord.js - Imagine a bot
•Created by sludge on 9/6/2022 in #djs-questions
autocomplete option based on other options
I've double checked the docs and had a look through the dev portal but can't find a definitive yes/no answer on whether or not this is possible: I have a command with two options that use autocomplete. getting the autocomplete choices is not an issue for the first, but I'm curious if it's possible to further filter the second options choices based on the option chosen in the first autocomplete.
I know the user can change the values etc and I can account for all that but just curious if what I want to achieve is even possible
5 replies