Don't allow duplicate registrations

1f66bc775653664535355a4d4cf22884d292f3de

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

2 files changed, +5 -3Ignore whitespace
public/scripts/macros.js+2 -2
@@ -50,8 +50,8 @@ export class MacrosParser {
50 * @returns {IterableIterator<CustomMacro>}50 * @returns {IterableIterator<CustomMacro>}
51 */51 */
52 static [Symbol.iterator] = function* () {52 static [Symbol.iterator] = function* () {
53 for (const macro of this.#macros.values()) {53 for (const macro of MacrosParser.#macros.keys()) {
54 yield { key: macro, description: this.#descriptions.get(macro) };54 yield { key: macro, description: MacrosParser.#descriptions.get(macro) };
55 }55 }
56 };56 };
5757
public/scripts/slash-commands/SlashCommandParser.js+3 -1
@@ -23,6 +23,7 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js';
23import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js';23import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js';
24import { SlashCommandBreak } from './SlashCommandBreak.js';24import { SlashCommandBreak } from './SlashCommandBreak.js';
25import { MacrosParser } from '../macros.js';25import { MacrosParser } from '../macros.js';
26import { t } from '../i18n.js';
2627
27/** @typedef {import('./SlashCommand.js').NamedArgumentsCapture} NamedArgumentsCapture */28/** @typedef {import('./SlashCommand.js').NamedArgumentsCapture} NamedArgumentsCapture */
28/** @typedef {import('./SlashCommand.js').NamedArguments} NamedArguments */29/** @typedef {import('./SlashCommand.js').NamedArguments} NamedArguments */
@@ -496,7 +497,8 @@ export class SlashCommandParser {
496 (li.querySelector('tt').remove(),li.innerHTML),497 (li.querySelector('tt').remove(),li.innerHTML),
497 ));498 ));
498 for (const macro of MacrosParser) {499 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`));
500 }502 }
501 const result = new AutoCompleteNameResult(503 const result = new AutoCompleteNameResult(
502 macro.name,504 macro.name,