properly notify user if they’re trying to get an age role they already have

This commit is contained in:
kageru 2018-06-10 21:06:23 +02:00
parent e58d7dd614
commit f5454910d0

View File

@ -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 {
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
}
}