157
options.push(...command.input.choices);
158
}
160
>
// Generate completion items for each alias and option combination.
161
>
// If there are no options, generate a single completion item for the alias.
162
const aliases = Array.from(new Set([command.name].concat(command.aliases ?? [])));
163
aliases
164
.filter(alias => !addedAliases.has(alias))
165
.forEach(alias => {
167
>
.forEach(option => {
168
>
// Add a trailing space after the command (and sub command/option if present).
169
>
// This is so user can continue to type additional arguments after the command and option.
170
>
const insertText = `/${alias}${option.name ? ' ' + option.name : ''} `;
171
>
const description = option.description ?? command.description;
172
>
const argumentHint = option.argumentHint;
173
>
addedAliases.add(alias);
174
>
175
>
completionItems.push({
176
>
insertText,
177
>
rangeStart: rangeStart,
178
>
rangeEnd: rangeEnd,
179
>
attachment: {
180
>
type: MessageAttachmentKind.Simple,
181
>
label: insertText,
182
>
_meta: toCommandCompletionAttachmentMeta({
183
>
command: command.name,
184
>
...(description !== undefined ? { description } : {}),
185
>
...(argumentHint !== undefined ? { argumentHint } : {})
186
>
}),
187
>
},
188
>
});
189
>
});
190
});
191
}