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

fix(ClientOptions): make ClientOptions#intents returns an IntentsBitField #8617

Merged
merged 13 commits into from Oct 9, 2022
Merged

fix(ClientOptions): make ClientOptions#intents returns an IntentsBitField #8617

merged 13 commits into from Oct 9, 2022

Conversation

Idris1401
Copy link
Contributor

@Idris1401 Idris1401 commented Sep 11, 2022

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

I think it's better that ClientOptions#intents returns an instance of IntentsBitField instead of just a number.

Status and versioning classification:

  • 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

@almeidx
Copy link
Member

almeidx commented Sep 11, 2022

intents: IntentsBitField.resolve(client.options.intents),

intents: client.options.intents.bitfield,


const hasGuildsIntent = new IntentsBitField(this.manager.client.options.intents).has(GatewayIntentBits.Guilds);

const hasGuildsIntent = this.manager.client.options.intents.has(GatewayIntentBits.Guilds);

Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

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

If this is to be standardised, I guess the type when being accessed could be Omit<ClientOptions, "intents"> & { intents: IntentsBitField };?

@vercel
Copy link

vercel bot commented Sep 11, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
discord-js ✅ Ready (Inspect) Visit Preview Oct 9, 2022 at 8:02PM (UTC)
discord-js-guide ✅ Ready (Inspect) Visit Preview Oct 9, 2022 at 8:02PM (UTC)

@Idris1401
Copy link
Contributor Author

Idris1401 commented Sep 11, 2022

If this is to be standardised, I guess the type when being accessed could be Omit<ClientOptions, "intents"> & { intents: IntentsBitField };?

instead of BitFieldResolvable<GatewayIntentsString, number> (at line 4269 of index.d.ts) ?

@almeidx
Copy link
Member

almeidx commented Sep 11, 2022

No, here

public options: ClientOptions;

@Jiralite Jiralite added this to the discord.js v14.4 milestone Sep 11, 2022
@Jiralite
Copy link
Member

Please double-check the tests!

@vercel vercel bot temporarily deployed to Preview September 15, 2022 18:22 Inactive
@vercel vercel bot temporarily deployed to Preview September 15, 2022 19:43 Inactive
@vercel vercel bot temporarily deployed to Preview September 18, 2022 14:58 Inactive
Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

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

Would this need changing too?

this.debug(`[IDENTIFY] Shard ${this.id}/${client.options.shardCount} with intents: ${d.intents}`);

Previously, this emitted the bit field. However, it now emits the class (IntentsBitField { bitfield: 8192 } for example). It doesn't seem problematic either way.

@Idris1401
Copy link
Contributor Author

Would this need changing too?

this.debug(`[IDENTIFY] Shard ${this.id}/${client.options.shardCount} with intents: ${d.intents}`);

Previously, this emitted the bit field. However, it now emits the class (IntentsBitField { bitfield: 8192 } for example). It doesn't seem problematic either way.

so no need to change it? ._.

@vercel vercel bot temporarily deployed to Preview September 22, 2022 16:57 Inactive
@Idris1401 Idris1401 changed the title fix(ClientOptions): make ClientOptions#intents returns an IntentsBitField fix(ClientOptions): make ClientOptions#intents returns an IntentsBitField Sep 24, 2022
@kodiakhq kodiakhq bot merged commit 4c2955a into discordjs:main Oct 9, 2022
@Idris1401 Idris1401 deleted the my-new-feature branch October 9, 2022 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants