Don't allow duplicate registrations

1f66bc775653664535355a4d4cf22884d292f3de

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +5 -3Showing whitespace changes
public/scripts/macros.js+2 -2
@@ -50,8 +50,8 @@ export class MacrosParser {
5050 * @returns {IterableIterator<CustomMacro>}
5151 */
5252 static [Symbol.iterator] = function* () {
5353 for (const macro of thisMacrosParser.#macros.valueskeys()) {
5454 yield { key: macro, description: thisMacrosParser.#descriptions.get(macro) };
5555 }
5656 };
5757
public/scripts/slash-commands/SlashCommandParser.js+3 -1
@@ -23,6 +23,7 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js';
2323import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js';
2424import { SlashCommandBreak } from './SlashCommandBreak.js';
2525import { MacrosParser } from '../macros.js';
26+import { t } from '../i18n.js';
2627
2728/** @typedef {import('./SlashCommand.js').NamedArgumentsCapture} NamedArgumentsCapture */
2829/** @typedef {import('./SlashCommand.js').NamedArguments} NamedArguments */
@@ -496,7 +497,8 @@ export class SlashCommandParser {
496497 (li.querySelector('tt').remove(),li.innerHTML),
497498 ));
498499 for (const macro of MacrosParser) {
499- options.push(new MacroAutoCompleteOption(macro.name, `{{${macro.name}}}`, macro.description || 'No description provided'));
500+ if (options.find(it => it.name === macro.key)) continue;
501+ options.push(new MacroAutoCompleteOption(macro.key, `{{${macro.key}}}`, macro.description || t`No description provided`));
500502 }
501503 const result = new AutoCompleteNameResult(
502504 macro.name,