package commands import ( "fmt" "math/rand" "time" "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.") rand.Seed(time.Now().UnixNano()) calculationCode = randomBase64(20) level.RecalculateEverything(dg, m.GuildID) util.SendSuccessEmbed(dg, m.ChannelID, "Level recalculated successfully.") } const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+=" var calculationCode string func init() { rand.Seed(time.Now().UnixNano()) calculationCode = randomBase64(20) } func randomBase64(n int) string { b := make([]byte, n) for i := range b { b[i] = letterBytes[rand.Int63()%int64(len(letterBytes))] } return string(b) }