Skip to content

Commit

Permalink
fix: clear commands belogning to legacy plugins before reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 18, 2023
1 parent f77c59c commit 6a53997
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,17 @@ export class Config implements IConfig {
private insertLegacyPlugins(plugins: IPlugin[]) {
for (const plugin of plugins) {
this.plugins.set(plugin.name, plugin)

// Delete all commands from the legacy plugin so that we can re-add them.
// This is necessary because this.determinePriority will pick the initial
// command that was added, which won't have been converted by PluginLegacy yet.
for (const cmd of plugin.commands ?? []) {
this._commands.delete(cmd.id)
for (const alias of [...(cmd.aliases ?? []), ...(cmd.hiddenAliases ?? [])]) {
this._commands.delete(alias)
}
}

this.loadCommands(plugin)
}
}
Expand Down

0 comments on commit 6a53997

Please sign in to comment.