#Is it possible to pass a message to a shard on creation?

25 messages · Page 1 of 1 (latest)

tiny quarry
#

I can see there is clientoptions for shardArgs but I am not sure how to catch them in the client itself that is spawned from the shardmanager.

remote peakBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

tiny quarry
#

13.7.0
There isn't a stack trace as it is just a question

kind grove
#

Isn’t it just process.argv?

tiny quarry
#

ah that can work yes, thank you

#

I noticed I can likely just use internal sharding for what I need. Setting shards: 'auto' to an extent but I can't seem to access any slash commands now, any idea why?

dark glacier
tiny quarry
#

That process is as follows, as I said it works without the sharding client option so maybe somehow something here is incompatible?

#

guildCommands and globalCommands are initialised above being set to [] just in case you wondered

dark glacier
tiny quarry
dark glacier
tiny quarry
serene shoal
#

the deploy-commands script should be ran manually generally

tiny quarry
#

I see, but either way it is only ran once when the bot starts so it isn't much different to having it separate

#

The point is that it works and yet as soon as I add that sharding option into clientoptions it doesn't

dark glacier
#

Well, how/when do you call your deployment exactly?

tiny quarry
# dark glacier Well, how/when do you call your deployment exactly?

hmm I guess you mean how do I start the bot? I use pm2 index.js for dev and the equivalent node index.js locally
I actually found out it wasn't able to read my keys correctly due to an incorrect merge and so the command files wasn't being picked up as valid commands so this issue is resolved now

#

The whole reason for me doing this hasn't been resolved however

#

I had an idea in mind to basically use sharding as a way to let two instances of the bot avoid each other since they run in different guilds my prod guild and my dev guild but when running a command in dev it will go through the prod instance first and obviously not find a valid channel id on the wrong guild and then they both cancel each other out and the command fails. I am using process.argv to pass an argument to the startup which then decides which keys file it gets dev or prod version and that works, as does the sharding now seemingly but when running a command in dev it still is captured in prod. I.e shards:shardID and then based on that argument I passed to the script it will give either 0 or 1 for the shard ID and thus avoid them picking up on each other using a command they both have in the wrong guild

I realise this is a weird as heck use of shards but I wasn't sure what other approach to use. But I am asking here now, so maybe you guys have a far better approach sweat

The use case for this is simply I want to test while the prod instance is running but currently I have to shut it down to be able to avoid this conflict

dark glacier
#

Or invite prod too, but since they are different bot users their slashcommands will be seperate anyway, but I don’t know what other features your bot has that might interfere with each other

#

You‘d just need to make sure to deploy the commands with your dev bot‘s token too

#

But for dev version it‘s advisable to deploy them as guild commands and not globally (unless you want to test dm commands too)