blob: 35175e49c470e9ab53b6a6b2e32df17a35c12d48 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
'use strict';
const CommandInteraction = require('./CommandInteraction');
const CommandInteractionOptionResolver = require('./CommandInteractionOptionResolver');
/**
* Represents a command interaction.
* @extends {CommandInteraction}
*/
class ChatInputCommandInteraction extends CommandInteraction {
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 = ChatInputCommandInteraction;
|