diff --git a/command.go b/command.go index d369729..43eaeb4 100644 --- a/command.go +++ b/command.go @@ -177,13 +177,20 @@ func giveAgeRole(s *discordgo.Session, m *discordgo.MessageCreate) { for command, role := range config.RoleCommands { if m.Content == command { // Found the command that was triggered - // Now check if the user already has one of the roles + // This is a restriction imposed by my own wrapper, + // but working around it is not actually necessary for performance and makes the code uglier in other places. for _, newRole := range config.RoleCommands { for _, curRole := range Member.Roles { // If the user already has one of the available roles, tell him and exit if newRole == curRole { - s.ChannelMessageSend(dm.ID, "Baka, du kannst nur eine der Rollen haben.") - log.Printf("Denied Role %s to %s. User already has %s", roleName(s.State, curRole), userToString(m.Author), roleName(s.State, curRole)) + if curRole == role { + // User is trying to get the role they already have + s.ChannelMessageSend(dm.ID, "Baka, die Rolle hast du doch schon.") + log.Printf("Denied Role %s to %s. User already has %s", roleName(s.State, curRole), userToString(m.Author), roleName(s.State, curRole)) + } else { + s.ChannelMessageSend(dm.ID, "Baka, du kannst nur eine der Rollen haben.") + log.Printf("Denied Role %s to %s. User already has %s", roleName(s.State, curRole), userToString(m.Author), roleName(s.State, curRole)) + } return } }