From 13649d74d63dc37eb2ce9ee5c38a7e4c804f32b3 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 30 Jul 2025 22:36:44 +0200 Subject: [PATCH] centralize discord bot invitation links --- .../js/components/tournament/SettingsDialog.jsx | 17 ++++++++--------- resources/js/helpers/discord.js | 6 ++++++ resources/js/pages/DiscordBot.jsx | 6 ++---- 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 resources/js/helpers/discord.js diff --git a/resources/js/components/tournament/SettingsDialog.jsx b/resources/js/components/tournament/SettingsDialog.jsx index a40a0a1..ad2de57 100644 --- a/resources/js/components/tournament/SettingsDialog.jsx +++ b/resources/js/components/tournament/SettingsDialog.jsx @@ -9,6 +9,7 @@ import DiscordForm from './DiscordForm'; import DiscordSelect from '../common/DiscordSelect'; import Icon from '../common/Icon'; import ToggleSwitch from '../common/ToggleSwitch'; +import { INVITE_URL } from '../../helpers/discord'; import Tournament from '../../helpers/Tournament'; import i18n from '../../i18n'; @@ -17,7 +18,7 @@ const open = async tournament => { await axios.post(`/api/tournaments/${tournament.id}/open`); toastr.success(i18n.t('tournaments.openSuccess')); } catch (e) { - toastr.error(i18n.t('tournaments.openError')); + toastr.error(i18n.t('tournaments.openError', { error: e.message })); } }; @@ -26,7 +27,7 @@ const close = async tournament => { await axios.post(`/api/tournaments/${tournament.id}/close`); toastr.success(i18n.t('tournaments.closeSuccess')); } catch (e) { - toastr.error(i18n.t('tournaments.closeError')); + toastr.error(i18n.t('tournaments.closeError', { error: e.message })); } }; @@ -35,7 +36,7 @@ const lock = async tournament => { await axios.post(`/api/tournaments/${tournament.id}/lock`); toastr.success(i18n.t('tournaments.lockSuccess')); } catch (e) { - toastr.error(i18n.t('tournaments.lockError')); + toastr.error(i18n.t('tournaments.lockError', { error: e.message })); } }; @@ -44,7 +45,7 @@ const unlock = async tournament => { await axios.post(`/api/tournaments/${tournament.id}/unlock`); toastr.success(i18n.t('tournaments.unlockSuccess')); } catch (e) { - toastr.error(i18n.t('tournaments.unlockError')); + toastr.error(i18n.t('tournaments.unlockError', { error: e.message })); } }; @@ -53,7 +54,7 @@ const setDiscord = async (tournament, guild_id) => { await axios.post(`/api/tournaments/${tournament.id}/discord`, { guild_id }); toastr.success(i18n.t('tournaments.discordSuccess')); } catch (e) { - toastr.error(i18n.t('tournaments.discordError')); + toastr.error(i18n.t('tournaments.discordError', { error: e.message })); } }; @@ -62,12 +63,10 @@ const settings = async (tournament, params) => { await axios.post(`/api/tournaments/${tournament.id}/settings`, params); toastr.success(i18n.t('tournaments.settingsSuccess')); } catch (e) { - toastr.error(i18n.t('tournaments.settingsError')); + toastr.error(i18n.t('tournaments.settingsError', { error: e.message })); } }; -const inviteUrl = 'https://discordapp.com/oauth2/authorize?client_id=951113702839549982&scope=bot'; - const SettingsDialog = ({ onHide, show, @@ -140,7 +139,7 @@ const SettingsDialog = ({ {!tournament.discord ?