invite link when channels load fails
All checks were successful
Build and Push Docker Image / build (push) Successful in 16s

This commit is contained in:
Corban-Lee Jones 2024-10-12 18:26:14 +01:00
parent c8bae087f9
commit 56e125c0bf

View File

@ -64,9 +64,9 @@ $(document).on("selectedServerChange", async function() {
$(".sidebar .sidebar-item").prop("disabled", true);
try {
$(`.sidebar .sidebar-item[data-id="${serverId}"]`).removeClass("is-not-operational");
channels = await ajaxRequest(`/generate-channels?guild=${serverId}`, "GET");
_loadedChannels[serverId] = channels;
$(".sidebar .sidebar-item").prop("disabled", false);
}
catch (error) {
logError(error);
@ -74,6 +74,18 @@ $(document).on("selectedServerChange", async function() {
// Mark the sidebar item as non-operational
$(`.sidebar .sidebar-item[data-id="${serverId}"]`).addClass("is-not-operational");
const inviteBotToServer = () => {
window.open(
`https://discord.com/oauth2/authorize
?client_id=${discordClientId}
&permissions=2147534848
&scope=bot+applications.commands
&guild_id=${serverId}
&disable_guild_select=true`,
"_blank"
);
}
// Inform the user of the problem
createModal({
title: "Failed to Fetch Server Channels",
@ -83,14 +95,23 @@ $(document).on("selectedServerChange", async function() {
],
buttons: [
{
className: "btn-danger px-4",
iconClass: "bi-arrow-return-right",
text: "Invite the Bot",
className: "btn-primary me-3",
iconClass: "bi-envelope-plus",
closeModal: true,
onClick: () => { $(".sidebar .sidebar-item").prop("disabled", false); }
onClick: inviteBotToServer
},
{
className: "btn-secondary",
iconClass: "bi-arrow-return-right",
closeModal: true
}
]
});
}
finally {
$(".sidebar .sidebar-item").prop("disabled", false);
}
});