40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
"gitea.teamortix.com/chanbakjsd/Milen/level"
|
|
"gitea.teamortix.com/chanbakjsd/Milen/util"
|
|
)
|
|
|
|
func handleRecalculateLevel(dg *discordgo.Session, m *discordgo.MessageCreate, arguments []string) {
|
|
if !level.ShouldListen {
|
|
util.SendFailEmbed(dg, m.ChannelID, "Recalculation In Progress", "❌ Recalculation is already in progress!")
|
|
}
|
|
if len(arguments) == 0 {
|
|
util.SendFailEmbed(
|
|
dg, m.ChannelID, "Bot Owner Access Required",
|
|
"⚠️ This action might take a while and disable level calculation system.\nTo confirm, check console for launch code.",
|
|
)
|
|
fmt.Println("Level launch requested: " + calculationCode)
|
|
return
|
|
}
|
|
if arguments[0] != calculationCode {
|
|
util.SendFailEmbed(
|
|
dg, m.ChannelID, "Incorrect Launch Code", "You entered an incorrect code.",
|
|
)
|
|
}
|
|
util.SendSuccessEmbed(dg, m.ChannelID, "Level is being recalculated.")
|
|
calculationCode = util.RandomBase64(20)
|
|
level.RecalculateEverything(dg, m.GuildID)
|
|
util.SendSuccessEmbed(dg, m.ChannelID, "Level recalculated successfully.")
|
|
}
|
|
|
|
var calculationCode string
|
|
|
|
func init() {
|
|
calculationCode = util.RandomBase64(20)
|
|
}
|