modules/config: Move all configurable constants into config package

master
Luther Wen Xu 2019-11-27 20:06:42 +07:00
parent 05512cbbd2
commit 76b7707b2b
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
6 changed files with 20 additions and 13 deletions

@ -8,14 +8,11 @@ import (
"github.com/bwmarrin/discordgo"
"PermissionGacha/db"
"PermissionGacha/modules/config"
"PermissionGacha/modules/level"
"PermissionGacha/modules/log"
)
const notInGeneralNerf = 10
const generalChannelID = "645550570001924098"
var lastMessage = make(map[string]time.Time)
var incrementMutex = sync.Mutex{}
@ -25,8 +22,8 @@ func Reward(s *discordgo.Session, m *discordgo.MessageCreate) {
}
amountToIncrement := calculateIncrement(m.Author.ID)
if m.ChannelID != generalChannelID {
amountToIncrement /= notInGeneralNerf
if m.ChannelID != config.GeneralChannelID {
amountToIncrement /= config.NotInGeneralNerf
}
multiplier, err := db.GetPrestigeMultiplier(m.Author.ID)
if err != nil {

@ -8,13 +8,13 @@ import (
"github.com/bwmarrin/discordgo"
"PermissionGacha/db"
"PermissionGacha/modules/config"
"PermissionGacha/modules/level"
"PermissionGacha/modules/log"
"PermissionGacha/modules/roles"
)
const emojiCheck = "✅"
const prestigeRequirement = 90000
var prestigeList = make(map[string]string)
@ -28,7 +28,7 @@ func handlePrestigeCommand(s *discordgo.Session, args []string, m *discordgo.Mes
if err != nil {
return fmt.Errorf("commands: handlePrestigeCommand: error while getting current XP: %w", err)
}
newPrestigeLevel := xp/prestigeRequirement + 1
newPrestigeLevel := xp/config.PrestigeRequirement + 1
currentLevel, _ := level.ConvertXPIntoLevel(xp)
@ -52,7 +52,7 @@ func handlePrestigeCommand(s *discordgo.Session, args []string, m *discordgo.Mes
m.Author.ID,
currentPrestigeLevel,
newPrestigeLevel,
nextNearestLogicalPrestige, float64(xp)/float64(prestigeRequirement*(nextNearestLogicalPrestige-1))*100,
nextNearestLogicalPrestige, float64(xp)/float64(config.PrestigeRequirement*(nextNearestLogicalPrestige-1))*100,
lowerLevelWarning,
),
)
@ -86,7 +86,7 @@ func ListenPrestigeReact(s *discordgo.Session, m *discordgo.MessageReactionAdd)
log.Error(s, "checkPrestigeReact", "GetXP", err)
return
}
newPrestigeLevel := xp/prestigeRequirement + 1
newPrestigeLevel := xp/config.PrestigeRequirement + 1
go roles.RemoveAllLevelRoles(s, m.UserID)
err = db.SetPrestigeMultiplier(m.UserID, newPrestigeLevel)
if err != nil {

@ -0,0 +1,4 @@
package config
const GeneralChannelID = "645550570001924098"
const NotInGeneralNerf = 10

@ -0,0 +1,3 @@
package config
const PrestigeRequirement = 90000

@ -0,0 +1,3 @@
package config
const StarChannel = "645551408283648000"

@ -9,16 +9,16 @@ import (
"github.com/bwmarrin/discordgo"
"PermissionGacha/db"
"PermissionGacha/modules/config"
"PermissionGacha/modules/log"
)
const starEmoji = "⭐"
const starChannel = "645551408283648000"
var starboardMutex sync.Mutex
func ReactListener(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
if m.ChannelID == starChannel {
if m.ChannelID == config.StarChannel {
return
}
if m.Emoji.Name != starEmoji {
@ -81,7 +81,7 @@ func ReactListener(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
)
msg, err = s.ChannelMessageSendEmbed(
starChannel,
config.StarChannel,
&discordgo.MessageEmbed{
Title: "Starred Message",
Description: content,