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() { async function loadBot() {
const res = await axios.get(`${API_URL}/user/whitelabel/`); const res = await axios.get(`${API_URL}/user/whitelabel/`);
if (res.status !== 200 || !res.data.success) { if (res.status !== 200 || !res.data.success) {
if (res.status === 402) {
window.location.replace("https://ticketsbot.net/premium");
return false;
}
if (res.status !== 404) { if (res.status !== 404) {
notifyError(res.data.error); notifyError(res.data.error);
} }
return; return true;
} }
bot = res.data; bot = res.data;
return true;
} }
async function loadErrors() { 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'); 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 () => { withLoadingScreen(async () => {
if (await checkPremium()) { if (await loadBot()) {
await loadBot();
await loadErrors(); await loadErrors();
await loadInteractionUrl(); await loadInteractionUrl();
await loadPublicKey(); await loadPublicKey();

2
go.mod
View File

@ -20,7 +20,7 @@ require (
github.com/jackc/pgx/v4 v4.7.1 github.com/jackc/pgx/v4 v4.7.1
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c
github.com/pkg/errors v0.9.1 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/sirupsen/logrus v1.5.0
github.com/ulule/limiter/v3 v3.5.0 github.com/ulule/limiter/v3 v3.5.0
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a