From d35ae1f243da17e533fc006919fe7d0c5710cbb9 Mon Sep 17 00:00:00 2001 From: rxdn <29165304+rxdn@users.noreply.github.com> Date: Sun, 1 Aug 2021 13:32:22 +0100 Subject: [PATCH] Hide claim button --- app/http/endpoints/api/settings/settings.go | 6 ++++++ app/http/endpoints/api/settings/updatesettings.go | 5 +++++ frontend/src/components/manage/SettingsCard.svelte | 5 +++-- frontend/src/js/constants.js | 2 +- go.mod | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/http/endpoints/api/settings/settings.go b/app/http/endpoints/api/settings/settings.go index 299a9b9..d9afa9e 100644 --- a/app/http/endpoints/api/settings/settings.go +++ b/app/http/endpoints/api/settings/settings.go @@ -9,6 +9,7 @@ import ( ) type Settings struct { + database.Settings Prefix string `json:"prefix"` WelcomeMessaage string `json:"welcome_message"` TicketLimit uint8 `json:"ticket_limit"` @@ -28,6 +29,11 @@ func GetSettingsHandler(ctx *gin.Context) { group, _ := errgroup.WithContext(context.Background()) + group.Go(func() (err error) { + settings.Settings, err = dbclient.Client.Settings.Get(guildId) + return + }) + // prefix group.Go(func() (err error) { settings.Prefix, err = dbclient.Client.Prefix.Get(guildId) diff --git a/app/http/endpoints/api/settings/updatesettings.go b/app/http/endpoints/api/settings/updatesettings.go index 5a76df9..44d7c3f 100644 --- a/app/http/endpoints/api/settings/updatesettings.go +++ b/app/http/endpoints/api/settings/updatesettings.go @@ -24,6 +24,7 @@ func UpdateSettingsHandler(ctx *gin.Context) { channels := cache.Instance.GetGuildChannels(guildId) // TODO: Errors + settings.updateSettings(guildId) validPrefix := settings.updatePrefix(guildId) validWelcomeMessage := settings.updateWelcomeMessage(guildId) validTicketLimit := settings.updateTicketLimit(guildId) @@ -46,6 +47,10 @@ func UpdateSettingsHandler(ctx *gin.Context) { } // TODO: Return error +func (s *Settings) updateSettings(guildId uint64) { + go dbclient.Client.Settings.Set(guildId, s.Settings) +} + func (s *Settings) updatePrefix(guildId uint64) bool { if s.Prefix == "" || len(s.Prefix) > 8 { return false diff --git a/frontend/src/components/manage/SettingsCard.svelte b/frontend/src/components/manage/SettingsCard.svelte index 7925a1e..76063e3 100644 --- a/frontend/src/components/manage/SettingsCard.svelte +++ b/frontend/src/components/manage/SettingsCard.svelte @@ -19,11 +19,12 @@ -
+
+
-
+
diff --git a/frontend/src/js/constants.js b/frontend/src/js/constants.js index c8ba09c..9a4f67d 100644 --- a/frontend/src/js/constants.js +++ b/frontend/src/js/constants.js @@ -1,4 +1,4 @@ -export const API_URL = env.API_URL || "http://192.168.90.213:3000" +export const API_URL = env.API_URL || "http://localhost:3000" export const PLACEHOLDER_DOCS_URL = "https://docs.ticketsbot.net/setup/placeholders.html" export const OAUTH = { diff --git a/go.mod b/go.mod index 32771a6..6c2ca0d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/BurntSushi/toml v0.3.1 github.com/TicketsBot/archiverclient v0.0.0-20210220155137-a562b2f1bbbb github.com/TicketsBot/common v0.0.0-20210727134627-35eb7ed03a44 - github.com/TicketsBot/database v0.0.0-20210728151044-f205b228de2d + github.com/TicketsBot/database v0.0.0-20210801121328-1e2e1c5e3346 github.com/TicketsBot/worker v0.0.0-20210727130432-3df3cd1246a3 github.com/apex/log v1.1.2 github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff // indirect