From a89935beb603f70ad0e7ca4c8963e31f6c947a0e Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Mon, 18 Nov 2019 14:42:20 +0800 Subject: [PATCH] xp: Fix max level display --- messageCreate.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/messageCreate.go b/messageCreate.go index e01c1dc..f2eb461 100644 --- a/messageCreate.go +++ b/messageCreate.go @@ -19,8 +19,15 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func handleXPRequest(s *discordgo.Session, m *discordgo.MessageCreate) { level, xp := getLevelAndXP(s, m.Author.ID) + levelUpRequirement := levelUpRequirementCache[level-1] + if level > 1 { + levelUpRequirement -= levelUpRequirementCache[level-2] + } s.ChannelMessageSend( m.ChannelID, - fmt.Sprintf("<@%s> is now level %d. (%d XP/%d XP)", m.Author.ID, level, xp, levelUpRequirementCache[level-1]), + fmt.Sprintf( + "<@%s> is now level %d. (%d XP/%d XP)", + m.Author.ID, level, xp, levelUpRequirement, + ), ) }