diff options
| author | Anhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me> | 2024-04-14 21:44:11 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus.morhtuuzh@proton.me> | 2024-04-14 21:44:11 +0200 |
| commit | 1a36ecd053f882fb7b32a98559d38b3542b29255 (patch) | |
| tree | 87364a5c37b94b660aac4586603c6f3272f264e5 /xp/member.go | |
| parent | 3e06848f7280d03af7d2aacd6b4146ec7cf7c04e (diff) | |
feat(xp): gain from vocal
Diffstat (limited to 'xp/member.go')
| -rw-r--r-- | xp/member.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/xp/member.go b/xp/member.go index 751bbd7..e3714fa 100644 --- a/xp/member.go +++ b/xp/member.go @@ -2,6 +2,7 @@ package xp import ( "github.com/anhgelus/gokord" + "github.com/bwmarrin/discordgo" "gorm.io/gorm" ) @@ -20,3 +21,14 @@ func (c *Copaing) Load() *Copaing { func (c *Copaing) Save() { gokord.DB.Save(c) } + +func (c *Copaing) AddXP(s *discordgo.Session, xp uint, fn func(uint, uint)) { + pastLevel := Level(c.XP) + c.XP += xp + c.Save() + newLevel := Level(c.XP) + if newLevel > pastLevel { + fn(c.XP, newLevel) + onNewLevel(s, newLevel) + } +} |
