| 1 | import { AutoCompleteOption } from '../autocomplete/AutoCompleteOption.js'; |
| 2 | import { SlashCommand } from './SlashCommand.js'; |
| 3 | import { SlashCommandNamedArgument } from './SlashCommandArgument.js'; |
| 4 | |
| 5 | export class SlashCommandNamedArgumentAutoCompleteOption extends AutoCompleteOption { |
| 6 | /** @type {SlashCommandNamedArgument} */ arg; |
| 7 | /** @type {SlashCommand} */ cmd; |
| 8 | |
| 9 | /** |
| 10 | * @param {SlashCommandNamedArgument} arg |
| 11 | */ |
| 12 | constructor(arg, cmd) { |
| 13 | super(`${arg.name}=`); |
| 14 | this.arg = arg; |
| 15 | this.cmd = cmd; |
| 16 | } |
| 17 | |
| 18 | |
| 19 | renderItem() { |
| 20 | let li; |
| 21 | li = this.makeItem(this.name, '⌗', true, [], [], null, `${this.arg.isRequired ? '' : '(optional) '}${this.arg.description ?? ''}`); |
| 22 | li.setAttribute('data-name', this.name); |
| 23 | li.setAttribute('data-option-type', 'namedArgument'); |
| 24 | return li; |
| 25 | } |
| 26 | |
| 27 | |
| 28 | renderDetails() { |
| 29 | return this.cmd.renderHelpDetails(); |
| 30 | } |
| 31 | } |