Don't allow duplicate registrations

This commit is contained in:
Cohee
2025-01-11 23:18:03 +02:00
parent 1dccb08cd6
commit 1f66bc7756
2 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js';
import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js';
import { SlashCommandBreak } from './SlashCommandBreak.js';
import { MacrosParser } from '../macros.js';
import { t } from '../i18n.js';
/** @typedef {import('./SlashCommand.js').NamedArgumentsCapture} NamedArgumentsCapture */
/** @typedef {import('./SlashCommand.js').NamedArguments} NamedArguments */
@ -496,7 +497,8 @@ export class SlashCommandParser {
(li.querySelector('tt').remove(),li.innerHTML),
));
for (const macro of MacrosParser) {
options.push(new MacroAutoCompleteOption(macro.name, `{{${macro.name}}}`, macro.description || 'No description provided'));
if (options.find(it => it.name === macro.key)) continue;
options.push(new MacroAutoCompleteOption(macro.key, `{{${macro.key}}}`, macro.description || t`No description provided`));
}
const result = new AutoCompleteNameResult(
macro.name,