#Is it possible to pass a message to a shard on creation?
25 messages · Page 1 of 1 (latest)
• 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.
13.7.0
There isn't a stack trace as it is just a question
Isn’t it just process.argv?
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?
That shouldn’t affect slashcommands at all, weird… when you say you can’t access them do you mean they don’t show in the app or the interaction doesn’t respond or what?
They don't show in the app yeah, I did a bit more digging and were it pushes the commands seems to be the issue as the array I store them in before sending seems to be empty before sending. I don't have a clue how that is possible tho given that it works without that single line for sharing and in that case the array it sends has the commands
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
And how do you call that file? Because ideally you would only deploy your commands when you changed something so you wouldn’t call that in your normal bot/client process. In that Case it won’t be affected by sharding at all
This is more of an experimentation so I don't actually have such a thing setup, it is just restarting the bot at the minute to grab any new files/command
By at the minute do you mean it restarts every minute? Because that would get you ratelimited pretty fast (even faster with sharding)
No by at the minute I mean I haven't added that ability yet, the bot runs this code on startup and those commands can't be updated or changed until I manually restart the bot
the deploy-commands script should be ran manually generally
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
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 
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
Use two different bot user/applications/tokens for dev and prod bot and invite dev to your dev guild only, don’t invite prod to it.
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)