From 23d97044ec58e8ceb8c7a1a6c9b02ce4cd6084a3 Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Sun, 24 May 2020 19:16:01 +0300 Subject: [PATCH] Simplify aliases adding - Removed duplicates check - Fixed docstring --- bot/subcommand.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/bot/subcommand.go b/bot/subcommand.go index d6c95d5..479cfcf 100644 --- a/bot/subcommand.go +++ b/bot/subcommand.go @@ -390,28 +390,13 @@ func (sub *Subcommand) SetPlumb(methodName string) { sub.plumbed = sub.FindCommand(methodName) } -// AddAliases add alias(es) to specific command (defined with MethodName). -// This removes silently all duplicate aliases. Use this instead overwriting aliases -// for safety reasons (duplicates). +// AddAliases add alias(es) to specific command (defined with commandName). func (sub *Subcommand) AddAliases(commandName string, aliases ...string) { // Get command command := sub.FindCommand(commandName) - // Merge current aliases for duplicate removing - aliases = append(aliases, command.Aliases...) - - // Remove all duplicate aliases - keys := make(map[string]bool) - var uniqueAliases []string - for _, alias := range aliases { - if _, value := keys[alias]; !value { - keys[alias] = true - uniqueAliases = append(uniqueAliases, alias) - } - } - // Write new listing of aliases - command.Aliases = uniqueAliases + command.Aliases = append(command.Aliases, aliases) } func lowerFirstLetter(name string) string {