Fix whitelabel page

This commit is contained in:
rxdn 2021-07-01 12:56:33 +01:00
parent 1e2ae09d71
commit 374b050338
2 changed files with 9 additions and 19 deletions

View File

@ -265,13 +265,19 @@
async function loadBot() {
const res = await axios.get(`${API_URL}/user/whitelabel/`);
if (res.status !== 200 || !res.data.success) {
if (res.status === 402) {
window.location.replace("https://ticketsbot.net/premium");
return false;
}
if (res.status !== 404) {
notifyError(res.data.error);
}
return;
return true;
}
bot = res.data;
return true;
}
async function loadErrors() {
@ -330,24 +336,8 @@
notifySuccess('Slash commands have been created. Please note, Discord may take up to an hour to show them in your client');
}
async function checkPremium() {
const res = await axios.get(`${API_URL}/api/${guildId}/premium`);
if (res.status !== 200) {
notifyError(res.data.error);
return;
}
let isWhitelabel = res.data.tier >= 1;
if (!isWhitelabel) {
window.location.replace("https://ticketsbot.net/premium");
}
return isWhitelabel;
}
withLoadingScreen(async () => {
if (await checkPremium()) {
await loadBot();
if (await loadBot()) {
await loadErrors();
await loadInteractionUrl();
await loadPublicKey();

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/jackc/pgx/v4 v4.7.1
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
github.com/pkg/errors v0.9.1
github.com/rxdn/gdl v0.0.0-20210629143956-f248d37cb604
github.com/rxdn/gdl v0.0.0-20210701115435-816eb486d5d0
github.com/sirupsen/logrus v1.5.0
github.com/ulule/limiter/v3 v3.5.0
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a