discord.js-selfbot-v13/src/structures/CommandInteraction.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

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