Possible to spawn for a single server with sharding?

I'm looking to have my bot do some specific processes in my server alone using a cron job (assigning roles based on database values, etc). I'd prefer to save the resources of spinning up and connecting to every server & several shards when running this. Is it possible to spawn an instance of the bot targeting a single server? Or should I just make a whole new bot for this? Thanks in advance <:pepe_pray:1011147706539966525>
7 Replies
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
Syjalo
Syjalo17mo ago
Neither you nor Discord can manage which servers the shard will manage. This is done by a formula.
d.js docs
d.js docs17mo ago
discord Gateway: Sharding To enable sharding on a connection, the user should send the shard array in the Identify payload. The first item in this array should be the zero-based integer value of the current shard, while the second represents the total number of shards. DMs will only be sent to shard 0. To calculate be... read more
billytheape
billytheape17mo ago
Is it possible to know ahead of time which shard the server will be on, and only spin up that one shard? Ah I see the formula... Perhaps I can figure it out shard_id = (guild_id >> 22) % num_shards Might just be easier to make a new bot though I guess
d.js docs
d.js docs17mo ago
Documentation suggestion for @billytheape.eth:method (static) ShardClientUtil.shardIdForGuildId() Get the shard id for a given guild id.
Syjalo
Syjalo17mo ago
You can also use this
billytheape
billytheape17mo ago
Thank you