Discord community: role sync, announcements webhook, launcher invite
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjMbLQujBHunCCu5GpsHaT
This commit is contained in:
11 files changed
+513
-2
No files matched your search
@@ -211,6 +211,17 @@ pub async fn discord_connection(state: State<'_, AppState>) -> Res<serde_json::V
|
||||
response.json().await.map_err(err)
|
||||
}
|
||||
|
||||
/// The community invite link and whether this account is linked.
|
||||
#[tauri::command]
|
||||
pub async fn discord_info(state: State<'_, AppState>) -> Res<serde_json::Value> {
|
||||
let req = account_api(&state, reqwest::Method::GET, "/account/discord").await?;
|
||||
let response = req.send().await.map_err(err)?;
|
||||
if !response.status().is_success() {
|
||||
return Err(accounts::panel_error(response).await.to_string());
|
||||
}
|
||||
response.json().await.map_err(err)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn discord_link_start(state: State<'_, AppState>) -> Res<serde_json::Value> {
|
||||
let req = account_api(&state, reqwest::Method::GET, "/auth/discord/start?kind=link").await?;
|
||||
|
||||
@@ -57,6 +57,7 @@ pub fn run() {
|
||||
commands::discord_sign_in_poll,
|
||||
commands::request_password_reset,
|
||||
commands::discord_connection,
|
||||
commands::discord_info,
|
||||
commands::discord_link_start,
|
||||
commands::discord_unlink,
|
||||
commands::register_panel,
|
||||
|
||||
@@ -17,9 +17,11 @@
|
||||
const serverAccount = $derived(activeAccount()?.kind === 'panel');
|
||||
let discordConnection = $state<{id: string; name: string} | null>(null);
|
||||
let discordBusy = $state(false);
|
||||
let discordInvite = $state('');
|
||||
$effect(() => {
|
||||
if (serverAccount && app.settingsTab === 'account') {
|
||||
invoke<{id: string; name: string} | null>('discord_connection').then(x => discordConnection = x).catch(() => discordConnection = null);
|
||||
invoke<{invite_url: string}>('discord_info').then(x => discordInvite = x.invite_url ?? '').catch(() => discordInvite = '');
|
||||
}
|
||||
});
|
||||
async function linkDiscord() {
|
||||
@@ -363,6 +365,9 @@
|
||||
{:else}
|
||||
<button disabled={discordBusy} onclick={linkDiscord}>{discordBusy ? 'Waiting for Discord…' : 'Connect Discord'}</button>
|
||||
{/if}
|
||||
{#if discordInvite}
|
||||
<button class="primary" onclick={() => openUrl(discordInvite)}>Join the community Discord</button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{:else if app.settingsTab === 'skin'}
|
||||
|
||||
Reference in new issue
Block a user