discord.js-selfbot-v13/src/structures/CommandInteraction.js
March 7th 7dfdef46a5 Downgrade to v13
[vi] cảm giác đau khổ
2022-03-24 17:55:32 +07:00

42 lines
1.2 KiB
JavaScript

'use strict';
const BaseCommandInteraction = require('./BaseCommandInteraction');
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
/**
* Represents a command interaction.
* @extends {BaseCommandInteraction}
*/
class CommandInteraction extends BaseCommandInteraction {
constructor(client, data) {
super(client, data);
/**
* The options passed to the command.
* @type {CommandInteractionOptionResolver}
*/
this.options = new CommandInteractionOptionResolver(
this.client,
data.data.options?.map(option => this.transformOption(option, data.data.resolved)) ?? [],
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;