modules/commands/level: Do not display percentage on max level

master
Luther Wen Xu 2019-12-13 18:52:06 +07:00
parent e9d2db3023
commit cc9b770cf6
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 18 additions and 7 deletions

@ -6,6 +6,7 @@ import (
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
"PermissionGacha/modules/config"
"PermissionGacha/modules/level" "PermissionGacha/modules/level"
) )
@ -21,12 +22,22 @@ func handleLevelCommand(s *discordgo.Session, args []string, m *discordgo.Messag
if xp > levelUpRequirement { if xp > levelUpRequirement {
xp -= 100 xp -= 100
} }
s.ChannelMessageSend( if levels < len(config.LevelRoles) {
m.ChannelID, s.ChannelMessageSend(
fmt.Sprintf( m.ChannelID,
"<@%s> is now level %d. (%d XP/%d XP) [%.1f%%]", fmt.Sprintf(
m.Author.ID, levels, xp, levelUpRequirement, float64(xp)/float64(levelUpRequirement)*100, "<@%s> is now level %d. (%d XP/%d XP) [%.1f%%]",
), m.Author.ID, levels, xp, levelUpRequirement, float64(xp)/float64(levelUpRequirement)*100,
) ),
)
} else {
s.ChannelMessageSend(
m.ChannelID,
fmt.Sprintf(
"<@%s> is now level %d. (%d XP) [MAX LEVEL]",
m.Author.ID, levels, xp,
),
)
}
return nil return nil
} }