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(CommandInteraction): cmds with no options throw error #5734

Merged
merged 2 commits into from Jun 3, 2021

Conversation

iShibi
Copy link
Contributor

@iShibi iShibi commented Jun 2, 2021

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

cough So, I totally forgot about slash cmds with no options in #5705. The options param in CommandInteraction#_createOptionsCollection would be undefined for such cmds and thus iterating over it will throw error. This PR fixes the issue by returning an empty collection when options is undefined. I did think of making CommandInteraction#options null at first:

this.options = data.data?.options ? this._createOptionsCollection(data.data.options, data.data.resolved) : null;

but then I saw that before #5705, it was set to an empty array for cmds that have no options, so I went with the empty collection fix.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes

@iShibi
Copy link
Contributor Author

iShibi commented Jun 2, 2021

The typings for CommandInterationOption#options were also not updated, fixed it in the above commit. No, idea what's up with the changes that linter made tho

Copy link

@imyanice imyanice left a comment

Choose a reason for hiding this comment

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

This will fix an error who is throw when an interaction is received.

Copy link

@imyanice imyanice left a comment

Choose a reason for hiding this comment

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

This will fix an error who is throw when an interaction is received.

@iCrawl iCrawl merged commit af2fad9 into discordjs:master Jun 3, 2021
@iShibi iShibi deleted the fix-options branch June 15, 2021 15:01
@iCrawl iCrawl added this to the Version 13 milestone Jun 27, 2021
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.

None yet

5 participants