whatshard

Based on the discord developer docs for sharding: https://discord.com/developers/docs/topics/gateway#sharding

Sharedunrated

Content

21 lines
{=():}
{=(COMMENT):Get args into a separate variable for use later.}
{=(joinedargs):{join(~):{args}}}
{=(arg1):{list(0):{joinedargs}}}
{=(arg2):{list(1):{joinedargs}}}

{=(COMMENT):If there are no args, show the usage and stop execution}
{{if(=={arg1}):blacklist(Usage: `[p]whatshard <num shards> [server ID]`):{server(id)}}}

{=(COMMENT):Get a variable with shard count (from args) and server ID (from args, or current server if no arg)}
{=(shards):{arg1}}
{=(guild):{if(=={arg2}):{server(id)}|{arg2}}}

{=(COMMENT):Makes sure both arguments are numbers. Based on !tips isnum }
{{any({m:sgn({shards})}!=1|{m:sgn({guild})}!=1):blacklist(Invalid input.):{server(id)}}}

{=(COMMENT):This is where it does the math to get the shard. Based on discord developer docs.}
{=(result):{m:trunc(trunc({guild}/(2^22))%{shards})}}

{=(COMMENT):Send the output!}
Server `{guild}` is on shard **{result}/{shards}**.
Raw JSON
{
  "id": 611680,
  "created_at": "2021-02-16T21:19:10.000Z",
  "tag_name": "whatshard",
  "nsfw": false,
  "owner_id": "489484338514100234",
  "uses": 31,
  "description": "Based on the discord developer docs for sharding: https://discord.com/developers/docs/topics/gateway#sharding\n",
  "restricted": false,
  "shared": true,
  "deleted": false,
  "safe": "unrated",
  "hidden": false,
  "guild_id": "636003276881657857",
  "sharer": "489484338514100234",
  "content": "{=():}\n{=(COMMENT):Get args into a separate variable for use later.}\n{=(joinedargs):{join(~):{args}}}\n{=(arg1):{list(0):{joinedargs}}}\n{=(arg2):{list(1):{joinedargs}}}\n\n{=(COMMENT):If there are no args, show the usage and stop execution}\n{{if(=={arg1}):blacklist(Usage: `[p]whatshard <num shards> [server ID]`):{server(id)}}}\n\n{=(COMMENT):Get a variable with shard count (from args) and server ID (from args, or current server if no arg)}\n{=(shards):{arg1}}\n{=(guild):{if(=={arg2}):{server(id)}|{arg2}}}\n\n{=(COMMENT):Makes sure both arguments are numbers. Based on !tips isnum }\n{{any({m:sgn({shards})}!=1|{m:sgn({guild})}!=1):blacklist(Invalid input.):{server(id)}}}\n\n{=(COMMENT):This is where it does the math to get the shard. Based on discord developer docs.}\n{=(result):{m:trunc(trunc({guild}/(2^22))%{shards})}}\n\n{=(COMMENT):Send the output!}\nServer `{guild}` is on shard **{result}/{shards}**.",
  "embed": "{}",
  "last_fetched": "2026-10-21T00:18:57.403Z"
}