correct authentication
This commit is contained in:
@ -139,12 +139,18 @@ async function fetch_channels(guild_id) {
|
||||
const event = new Event("channelsLoading");
|
||||
document.dispatchEvent(event);
|
||||
|
||||
let hasError = false;
|
||||
|
||||
await fetch(`/dashboard/api/guild/${guild_id}/channels`)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (data.error) {
|
||||
if (data.error === "Bot not in guild") {
|
||||
switch_pane("guild-error");
|
||||
hasError = true;
|
||||
} else if (data.error === "Incorrect permissions") {
|
||||
switch_pane("user-error");
|
||||
hasError = true;
|
||||
} else {
|
||||
show_error(data.error);
|
||||
}
|
||||
@ -156,6 +162,8 @@ async function fetch_channels(guild_id) {
|
||||
const event = new Event("channelsLoaded");
|
||||
document.dispatchEvent(event);
|
||||
});
|
||||
|
||||
return hasError;
|
||||
}
|
||||
|
||||
async function fetch_reminders(guild_id) {
|
||||
@ -416,19 +424,21 @@ document.addEventListener("guildSwitched", async (e) => {
|
||||
.forEach((el) => el.classList.remove("is-locked"));
|
||||
}
|
||||
|
||||
fetch_roles(e.detail.guild_id);
|
||||
fetch_templates(e.detail.guild_id);
|
||||
await fetch_channels(e.detail.guild_id);
|
||||
fetch_reminders(e.detail.guild_id);
|
||||
let hasError = await fetch_channels(e.detail.guild_id);
|
||||
if (!hasError) {
|
||||
fetch_roles(e.detail.guild_id);
|
||||
fetch_templates(e.detail.guild_id);
|
||||
fetch_reminders(e.detail.guild_id);
|
||||
|
||||
document.querySelectorAll("p.pageTitle").forEach((el) => {
|
||||
el.textContent = `${e.detail.guild_name} Reminders`;
|
||||
});
|
||||
document.querySelectorAll("select.channel-selector").forEach((el) => {
|
||||
el.addEventListener("change", (e) => {
|
||||
update_select(e.target);
|
||||
document.querySelectorAll("p.pageTitle").forEach((el) => {
|
||||
el.textContent = `${e.detail.guild_name} Reminders`;
|
||||
});
|
||||
});
|
||||
document.querySelectorAll("select.channel-selector").forEach((el) => {
|
||||
el.addEventListener("change", (e) => {
|
||||
update_select(e.target);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$loader.classList.add("is-hidden");
|
||||
});
|
||||
|
Reference in New Issue
Block a user