Don't allow duplicate registrations
| @@ -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 | }; |
| 57 | 57 | ||
| @@ -23,6 +23,7 @@ import { SlashCommandDebugController } from './SlashCommandDebugController.js'; | |||
| 23 | import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js'; | 23 | import { commonEnumProviders } from './SlashCommandCommonEnumsProvider.js'; |
| 24 | import { SlashCommandBreak } from './SlashCommandBreak.js'; | 24 | import { SlashCommandBreak } from './SlashCommandBreak.js'; |
| 25 | import { MacrosParser } from '../macros.js'; | 25 | import { MacrosParser } from '../macros.js'; |
| 26 | import { t } from '../i18n.js'; | ||
| 26 | 27 | ||
| 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, |