diff --git a/apps/home/static/home/js/servers.js b/apps/home/static/home/js/servers.js index 1a4e556..be3a65c 100644 --- a/apps/home/static/home/js/servers.js +++ b/apps/home/static/home/js/servers.js @@ -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); + } });