mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(CommandInteraction): add toString method (#6793)
This commit is contained in:
@@ -21,6 +21,21 @@ class CommandInteraction extends BaseCommandInteraction {
|
||||
this.transformResolved(data.data.resolved ?? {}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the command interaction.
|
||||
* This can then be copied by a user and executed again in a new command while keeping the option order.
|
||||
* @returns {string}
|
||||
*/
|
||||
toString() {
|
||||
const properties = [
|
||||
this.commandName,
|
||||
this.options._group,
|
||||
this.options._subcommand,
|
||||
...this.options._hoistedOptions.map(o => `${o.name}:${o.value}`),
|
||||
];
|
||||
return `/${properties.filter(Boolean).join(' ')}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CommandInteraction;
|
||||
|
||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -604,6 +604,7 @@ export type GuildCommandInteraction<Cached extends GuildCacheState = GuildCacheS
|
||||
|
||||
export class CommandInteraction extends BaseCommandInteraction implements GuildCachedInteraction<CommandInteraction> {
|
||||
public options: CommandInteractionOptionResolver;
|
||||
public toString(): string;
|
||||
}
|
||||
|
||||
export class CommandInteractionOptionResolver {
|
||||
|
||||
Reference in New Issue
Block a user