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(CommandInteraction): add toString method #6793

Merged
merged 2 commits into from Oct 12, 2021

Conversation

ImRodry
Copy link
Contributor

@ImRodry ImRodry commented Oct 8, 2021

Please describe the changes this PR makes and why it should be merged:
This PR adds a toString method to CommandInteraction that outputs a string that can be copied by a user in order to execute the same command again. There’s an upcoming update to the client text editor so I’m not sure how this will work once that’s out but this works fine at the moment

Example:
0850C856-EA6A-4875-87D2-BC2217607B5A

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)

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.

  1. Can we put this in the command interaction option resolver so context menu commands can utilise this too (as well as autocomplete when it is released)?
  2. If nearly all the checks stem from the command interaction option resolver, you might as well move it into there and have this method call it from there. This can deduplicate code if you go with the aforementioned point.

src/structures/CommandInteraction.js Outdated Show resolved Hide resolved
@ImRodry
Copy link
Contributor Author

ImRodry commented Oct 8, 2021

  • Can we put this in the command interaction option resolver so context menu commands can utilise this too (as well as autocomplete when it is released)?
  • If nearly all the checks stem from the command interaction option resolver, you might as well move it into there and have this method call it from there. This can deduplicate code if you go with the aforementioned point.
  1. No because context menus cannot be copied like application commands can. If they could I would’ve put this in BaseCommandInteraction
  2. I don’t think that makes any sense because you’re stringifying the command and not the options, and you can also stringify a command with no options

@iCrawl iCrawl added this to the Version 13.3 milestone Oct 12, 2021
@iCrawl iCrawl merged commit bd48e6d into discordjs:main Oct 12, 2021
@ImRodry ImRodry deleted the feat-commandinteraction-tostring branch October 12, 2021 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants