discord.js icon indicating copy to clipboard operation
discord.js copied to clipboard

feat(ApplicationCommand): add `toString()`

Open Squiddleton opened this issue 2 years ago • 6 comments

Please describe the changes this PR makes and why it should be merged: Adds ApplicationCommand#toString() in the format of </name:id> mentions. Please note that this does not currently account for subcommands: Discord still highlights the mention if only the base command name is in the mentions, however it is unclickable.

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)

Squiddleton avatar Nov 07 '22 01:11 Squiddleton

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

2 Ignored Deployments
Name Status Preview Updated
discord-js ⬜️ Ignored (Inspect) Nov 8, 2022 at 7:45PM (UTC)
discord-js-guide ⬜️ Ignored (Inspect) Nov 8, 2022 at 7:45PM (UTC)

vercel[bot] avatar Nov 07 '22 01:11 vercel[bot]

Please note that this does not currently account for subcommands: Discord still highlights the mention if only the base command name is in the mentions, however it is unclickable.

Works for me (and has for a very long time):

https://user-images.githubusercontent.com/33201955/200207719-5052ac18-6487-4af8-bd07-d81a65ac064d.mp4

I think this was initially going to be added in #8546, but @almeidx decided against it... maybe they can shed more light onto this as to why.

Jiralite avatar Nov 07 '22 01:11 Jiralite

Works for me (and has for a very long time):

I was referring to if a command has subcommands, and you attempt to type out only the format </name:id>, clicking it won't do anything in the client. This is the main downside of toString() without any parameters since the options are either 1) use the name without any subcommands (e.g. </request:id> in your case), or 2) pick the first/random subcommand name (e.g. </request close:id> which sacrifices consistency.

Squiddleton avatar Nov 07 '22 01:11 Squiddleton

Ah, thank you for clarifying.

Then, I wonder if this should be a method on the class vs. toString(). Then, I further wonder if that is necessary as discord.js already exports the application command mention formatter.

Jiralite avatar Nov 07 '22 01:11 Jiralite

One middle ground between those would be a toString() with optional subcommand/subcommand group parameters. Ignoring a toString() feels inconsistent with User/Role/Channel mentions, although adding parameters is inconsistent with native JS Object#toString().

discord.js already exports the application command mention formatter

Honestly, I had no idea this exists until now. I completely understand disregarding this since that accomplishes the same purpose, although having some form of it used on the main class would still be appreciated.

Squiddleton avatar Nov 07 '22 01:11 Squiddleton

I think this was initially going to be added in #8546, but @almeidx decided against it... maybe they can shed more light onto this as to why.

This was because the ApplicationCommand class includes all of the application commands (e.g. context menu commands), and the mention only works for Chat Input commands afaik

almeidx avatar Nov 07 '22 09:11 almeidx

@Squiddleton are you still working on this?

net-tech avatar Aug 17 '23 01:08 net-tech