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(Interaction): add guild guard #5955

Merged
merged 3 commits into from
Jun 29, 2021
Merged

feat(Interaction): add guild guard #5955

merged 3 commits into from
Jun 29, 2021

Conversation

papsavas
Copy link
Contributor

@papsavas papsavas commented Jun 28, 2021

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

closes #5809

This PR creates an inGuild() method both for Interaction and CommandInteraction checking if an interaction is used in a guild. Feel free to add suggestions, such as naming or implementation ,as i compeletely followed the ones from the issue

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
  • This PR changes the library's interface (methods or parameters added)

@monbrey
Copy link
Member

monbrey commented Jun 28, 2021

I like the idea, but I'm not sure it should be relying on two other getters for the validation. guildID and member are the only ones you receive data for in the constructor.

channel and guild both assume this is a bot user with the GUILDS intent enabled, which means this could return false negatives if those caches aren't complete.

@papsavas
Copy link
Contributor Author

papsavas commented Jun 28, 2021

@monbrey in that case i suppose there is no need for an inherited method in CommandInteraction, just one <Interaction>#inGuild()

@iCrawl iCrawl merged commit 87e8cdd into discordjs:master Jun 29, 2021
@papsavas papsavas deleted the interaction-guild-guard branch June 30, 2021 07:02
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.

Type guard for interactions in guilds
7 participants