Skip to content

Commit

Permalink
fix: 🥅 Added error catching for admins when saving a discord ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
JamsRepos committed Oct 30, 2023
1 parent d55c877 commit 134b03e
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions apps/wizarr-frontend/src/modules/settings/pages/Discord.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,26 @@
</p>
<div class="flex flex-col space-y-1">
<p class="text-xs font-semibold leading-tight tracking-tight text-gray-900 md:text-sm dark:text-gray-400">
{{ __("Please enter your Discord Server ID below. If you don't know how to get your Discord Server ID, please follow the instructions below.") }}
{{ __("Please enter your Discord Server ID below and ensure Server Widgets are enabled. If you don't know how to get your Discord Server ID or Enable Widgets, please follow the instructions below.") }}
</p>
<p class="text-sm text-gray-500 dark:text-gray-400">
<li>{{ __("First make sure you have Developer Mode enabled on your Discord by visiting your Discord settings and going to Appearance.") }}</li>
<li>{{ __("To get your Server ID right click on the server icon on the left hand sidebar") }}</li>
<li>{{ __('Click on "Copy ID" then paste it it in the box below') }}</li>
<p class="text-xs font-semibold leading-tight tracking-tight text-gray-900 md:text-sm dark:text-gray-400">
{{ __("Discord Server ID:") }}
</p>
<ul class="list-decimal">
<li>{{ __("First make sure you have Developer Mode enabled on your Discord by visiting your Discord settings and going to Appearance.") }}</li>
<li>{{ __("To get your Server ID right click on the server icon on the left hand sidebar.") }}</li>
<li>{{ __('Click on "Copy ID" then paste it it in the box below.') }}</li>
</ul>

<p class="text-xs font-semibold leading-tight tracking-tight text-gray-900 md:text-sm dark:text-gray-400">
{{ __("Enable Server Widget:") }}
</p>
<ul class="list-decimal">
<li>{{ __('To enable Server Widgets, navigate to your Server Settings.') }}</li>
<li>{{ __('Click "Widget" on the left hand sidebar.') }}</li>
<li>{{ __('Ensure the toggle for "Enable Server Widget" is checked.') }}</li>
</ul>
</p>
</div>
</div>
Expand Down Expand Up @@ -46,13 +60,17 @@ export default defineComponent({
const formData = new FormData();
formData.append("server_discord_id", this.serverId);
const validate = await this.$axios.get(`https://discord.com/api/guilds/${this.serverId}/widget.json`).catch((validation) => {
if (validation.response.data.code === 50004) this.$toast.error(this.__("Unable to save due to widgets being disabled on this server."));
});
const response = await this.$axios.put("/api/settings", formData).catch(() => {
this.$toast.error(this.__("Unable to save connection."));
});
if (!response?.data) return;
if (!response?.data || !validate?.data) return;
this.$toast.info("Discord Server ID saved successfully");
this.$toast.info("Discord Server ID saved successfully.");
},
syncSettings() {
this.$axios.get("/api/settings", { disableErrorToast: true }).then((response) => {
Expand Down

0 comments on commit 134b03e

Please sign in to comment.