From f5454910d07142ea74b9ebe45fe3a0fa6cc00428 Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 10 Jun 2018 21:06:23 +0200 Subject: [PATCH] =?UTF-8?q?properly=20notify=20user=20if=20they=E2=80=99re?= =?UTF-8?q?=20trying=20to=20get=20an=20age=20role=20they=20already=20have?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- command.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 } }