Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Shard): shard-specific broadcastEval/fetchClientValues + shard Id util #4991

Merged
merged 10 commits into from
Nov 22, 2020

Conversation

MattIPv4
Copy link
Contributor

@MattIPv4 MattIPv4 commented Nov 8, 2020

Please describe the changes this PR makes and why it should be merged:

Adds the ability to call broadcastEval and fetchClientValues from a shard to run on different target shard, instead of broadcasting to all and using an if in the given script to filter by shard.

Now you can target a shard directly:

const { ShardClientUtil } = require('discord.js');
const guild = '433980600391696384';

// Get the shard Id -- `client.shard.constructor.shardIdForGuildId` could also be used
const shard = ShardClientUtil.shardIdForGuildId(guild, 2);

// Get the guild from that shard only
const name = await client.shard.broadcastEval(`this.guilds.cache.get('${guild}').name`, shard);

return [name, shard, client.shardId];

We get back [JetBrains Community, 1, 0], so we can see it correctly went to the target shard and found the guild there.

Status

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Semantic versioning classification:

  • This PR changes the library's interface (methods or parameters added)
    • This PR includes breaking changes (methods removed or renamed, parameters moved or removed)
  • This PR only includes non-code changes, like changes to documentation, README, etc.

@MattIPv4 MattIPv4 changed the title feat(Shard): support shard argument in broadcastEval feat(Shard): support shard argument in broadcastEval/fetchClientValues Nov 8, 2020
@MattIPv4 MattIPv4 force-pushed the shard-specific-eval branch 2 times, most recently from 0cc926b to ccbb40c Compare November 8, 2020 13:56
src/sharding/ShardingManager.js Outdated Show resolved Hide resolved
src/sharding/ShardingManager.js Outdated Show resolved Hide resolved
src/sharding/ShardingManager.js Show resolved Hide resolved
src/sharding/ShardingManager.js Show resolved Hide resolved
src/util/Snowflake.js Outdated Show resolved Hide resolved
@MattIPv4 MattIPv4 force-pushed the shard-specific-eval branch 2 times, most recently from 6205d8a to 6aefbb3 Compare November 8, 2020 14:16
@MattIPv4 MattIPv4 marked this pull request as ready for review November 8, 2020 14:41
@MattIPv4 MattIPv4 force-pushed the shard-specific-eval branch from 6ff2d17 to 35d9e4d Compare November 8, 2020 14:49
Copy link
Contributor

@jonahsnider jonahsnider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code probably works but I have a few minor suggestions with the shardIdForGuildId function.

src/sharding/ShardClientUtil.js Outdated Show resolved Hide resolved
src/sharding/ShardClientUtil.js Outdated Show resolved Hide resolved
@MattIPv4 MattIPv4 force-pushed the shard-specific-eval branch from 7d2c438 to e0d6da9 Compare November 8, 2020 15:42
src/sharding/ShardClientUtil.js Outdated Show resolved Hide resolved
@MattIPv4 MattIPv4 force-pushed the shard-specific-eval branch from e0d6da9 to 4d1a66a Compare November 8, 2020 15:45
Copy link
Contributor

@jonahsnider jonahsnider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New edits look good.

@MattIPv4 MattIPv4 changed the title feat(Shard): support shard argument in broadcastEval/fetchClientValues feat(Shard): shard-specific broadcastEval/fetchClientValues + shard Id util Nov 8, 2020
@MattIPv4 MattIPv4 requested a review from kyranet November 8, 2020 21:17
Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

src/sharding/ShardClientUtil.js Outdated Show resolved Hide resolved
src/util/Snowflake.js Outdated Show resolved Hide resolved
src/sharding/ShardClientUtil.js Outdated Show resolved Hide resolved
typings/index.d.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants