This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
PermissionGacha/messageCreate.go

34 lines
663 B
Go

package main
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.Author.Bot {
return
}
go incrementXP(s, m.Author.ID)
if m.Content == "p!level" {
handleXPRequest(s, m)
}
}
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, levelUpRequirement,
),
)
}