feat(xp): gain from vocal
This commit is contained in:
parent
3e06848f72
commit
1a36ecd053
3 changed files with 112 additions and 8 deletions
12
xp/member.go
12
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue