Remove redundant settings

This commit is contained in:
rxdn 2023-09-13 02:16:06 +01:00
parent d873a4c221
commit 8e5018a5d7
5 changed files with 14 additions and 46 deletions

View File

@ -20,13 +20,11 @@ type (
TicketPermissions database.TicketPermissions `json:"ticket_permissions"`
Colours ColourMap `json:"colours"`
Prefix string `json:"prefix"`
WelcomeMessage string `json:"welcome_message"`
TicketLimit uint8 `json:"ticket_limit"`
Category uint64 `json:"category,string"`
ArchiveChannel *uint64 `json:"archive_channel,string"`
NamingScheme database.NamingScheme `json:"naming_scheme"`
PingEveryone bool `json:"ping_everyone"`
UsersCanClose bool `json:"users_can_close"`
CloseConfirmation bool `json:"close_confirmation"`
FeedbackEnabled bool `json:"feedback_enabled"`
@ -85,16 +83,6 @@ func GetSettingsHandler(ctx *gin.Context) {
return
})
// prefix
group.Go(func() (err error) {
settings.Prefix, err = dbclient.Client.Prefix.Get(guildId)
if err == nil && settings.Prefix == "" {
settings.Prefix = "t!"
}
return
})
// welcome message
group.Go(func() (err error) {
settings.WelcomeMessage, err = dbclient.Client.WelcomeMessages.Get(guildId)
@ -133,12 +121,6 @@ func GetSettingsHandler(ctx *gin.Context) {
return
})
// ping everyone
group.Go(func() (err error) {
settings.PingEveryone, err = dbclient.Client.PingEveryone.Get(guildId)
return
})
// naming scheme
group.Go(func() (err error) {
settings.NamingScheme, err = dbclient.Client.NamingScheme.Get(guildId)

View File

@ -29,14 +29,18 @@ func UpdateSettingsHandler(ctx *gin.Context) {
}
// Get a list of all channel IDs
channels := cache.Instance.GetGuildChannels(guildId)
botContext, err := botcontext.ContextForGuild(guildId)
if err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
channels, err := botContext.GetGuildChannels(guildId)
if err != nil {
ctx.JSON(500, utils.ErrorJson(err))
return
}
// Includes voting
premiumTier, err := rpc.PremiumClient.GetTierByGuildId(guildId, true, botContext.Token, botContext.RateLimiter)
if err != nil {
@ -73,19 +77,16 @@ func UpdateSettingsHandler(ctx *gin.Context) {
errStr = utils.Ptr(err.Error())
}
validPrefix := settings.updatePrefix(guildId)
validWelcomeMessage := settings.updateWelcomeMessage(guildId)
validTicketLimit := settings.updateTicketLimit(guildId)
validArchiveChannel := settings.updateArchiveChannel(channels, guildId)
validCategory := settings.updateCategory(channels, guildId)
validNamingScheme := settings.updateNamingScheme(guildId)
settings.updatePingEveryone(guildId)
settings.updateUsersCanClose(guildId)
settings.updateCloseConfirmation(guildId)
settings.updateFeedbackEnabled(guildId)
ctx.JSON(200, gin.H{
"prefix": validPrefix,
"welcome_message": validWelcomeMessage,
"ticket_limit": validTicketLimit,
"archive_channel": validArchiveChannel,
@ -254,15 +255,6 @@ func addToWaitGroup(group *errgroup.Group, guildId uint64, f func(uint64) error)
})
}
func (s *Settings) updatePrefix(guildId uint64) bool {
if s.Prefix == "" || len(s.Prefix) > 8 {
return false
}
go dbclient.Client.Prefix.Set(guildId, s.Prefix)
return true
}
func (s *Settings) updateWelcomeMessage(guildId uint64) bool {
if s.WelcomeMessage == "" || len(s.WelcomeMessage) > 4096 {
return false
@ -339,10 +331,6 @@ func (s *Settings) updateNamingScheme(guildId uint64) bool {
return true
}
func (s *Settings) updatePingEveryone(guildId uint64) {
go dbclient.Client.PingEveryone.Set(guildId, s.PingEveryone)
}
func (s *Settings) updateUsersCanClose(guildId uint64) {
go dbclient.Client.UsersCanClose.Set(guildId, s.UsersCanClose)
}

View File

@ -10,7 +10,6 @@
<span slot="header">General</span>
<div slot="content" class="col-1">
<div class="row">
<Input label="prefix (max len. 8)" placeholder="t!" col4 bind:value={data.prefix}/>
<Number label="per user simultaneous ticket limit" min=1 max=10 bind:value={data.ticket_limit}/>
<Dropdown label="Language" bind:value={data.language}>
<option value=null selected="selected">Server Default</option>
@ -325,11 +324,6 @@
notify("Warning", data.error);
}
if (!data.prefix) {
success = false;
notify("Warning", "Your prefix has not been saved.\nPrefixes must be between 1 - 8 characters in length.")
}
if (!data.welcome_message) {
success = false;
notify("Warning", "Your welcome message has not been saved.\nWelcome messages must be between 1 - 1000 characters in length.")

4
go.mod
View File

@ -6,9 +6,9 @@ require (
github.com/BurntSushi/toml v1.2.1
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc
github.com/TicketsBot/common v0.0.0-20230819234541-7678a70af5f1
github.com/TicketsBot/database v0.0.0-20230912230123-6e05ad6a515c
github.com/TicketsBot/database v0.0.0-20230913010851-15cd49b12133
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c
github.com/TicketsBot/worker v0.0.0-20230912230235-11b0d81ce899
github.com/TicketsBot/worker v0.0.0-20230913011504-268527c33489
github.com/apex/log v1.1.2
github.com/getsentry/sentry-go v0.24.0
github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607

8
go.sum
View File

@ -47,14 +47,18 @@ github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc h1:n15W8
github.com/TicketsBot/archiverclient v0.0.0-20220326163414-558fd52746dc/go.mod h1:2KcfHS0JnSsgcxZBs3NyWMXNQzEo67mBSGOyzHPWOCc=
github.com/TicketsBot/common v0.0.0-20230819234541-7678a70af5f1 h1:ulEWPU9i9uNPkduWyUZoIHgaKmoUoLW5LguCD2iXX7U=
github.com/TicketsBot/common v0.0.0-20230819234541-7678a70af5f1/go.mod h1:rZuaTbjajlxscl628aBgUGiUZcOVLvF6pfsPL+2JOac=
github.com/TicketsBot/database v0.0.0-20230912230123-6e05ad6a515c h1:Ptt7sp1ov7+HI9vovkuusqUD03+NNnqHEVkPqVg4UH4=
github.com/TicketsBot/database v0.0.0-20230912230123-6e05ad6a515c/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
github.com/TicketsBot/database v0.0.0-20230913010851-15cd49b12133 h1:YHwa9VFz7XGOh2WhoNJCo27kkLccpKd6myWip86olIs=
github.com/TicketsBot/database v0.0.0-20230913010851-15cd49b12133/go.mod h1:gAtOoQKZfCkQ4AoNWQUSl51Fnlqk+odzD/hZ1e1sXyI=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c h1:OqGjFH6mbE6gd+NqI2ARJdtH3UUvhiAkD0r0fhGJK2s=
github.com/TicketsBot/logarchiver v0.0.0-20220326162808-cdf0310f5e1c/go.mod h1:jgi2OXQKsd5nUnTIRkwvPmeuD/i7OhN68LKMssuQY1c=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261 h1:NHD5GB6cjlkpZFjC76Yli2S63/J2nhr8MuE6KlYJpQM=
github.com/TicketsBot/ttlcache v1.6.1-0.20200405150101-acc18e37b261/go.mod h1:2zPxDAN2TAPpxUPjxszjs3QFKreKrQh5al/R3cMXmYk=
github.com/TicketsBot/worker v0.0.0-20230912230235-11b0d81ce899 h1:wRS6ULtJpvi/VCYOM3TqtCvgvRqOGCoABF47JV/GMhc=
github.com/TicketsBot/worker v0.0.0-20230912230235-11b0d81ce899/go.mod h1:dL2waN1p4NaY21lD3NByvrYlgZ2KHVy8VgZaDAZDdSw=
github.com/TicketsBot/worker v0.0.0-20230913011223-524fc33d8c66 h1:10fUQPT6C4Ear+oq1LHGwgcqMmxFG0d+E5LiPH7s5j0=
github.com/TicketsBot/worker v0.0.0-20230913011223-524fc33d8c66/go.mod h1:GSQxOsd1HS5tQE2tqGAdYUwZsIDOaYYsLBgNI+fRZ08=
github.com/TicketsBot/worker v0.0.0-20230913011504-268527c33489 h1:usE+mwjUBZ43truAqeH2/AISRCYkB5wLyWZojcyho34=
github.com/TicketsBot/worker v0.0.0-20230913011504-268527c33489/go.mod h1:GSQxOsd1HS5tQE2tqGAdYUwZsIDOaYYsLBgNI+fRZ08=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=