LuaSecureDocumentationDashboard ↗
Integrations / Documentation

Connect Discord

Link a Discord account so the LuaSecure bot can recognise you.

Link your account

Two ways to connect Discord:

  • Sign in with Discord. On the sign-in or create-account page, choose Continue with Discord. This creates (or signs you into) your account and links Discord automatically.
  • Link from the dashboard. Select Discord to the left of New project, choose Link Discord, and approve Discord’s screen. The panel shows Linked only after the bot connection is saved. Your Discord name and profile photo appear on the dashboard. Email/password accounts can use this same Link Discord button. Run /link in Discord to verify your connection.

To connect a different account, open the Discord panel and choose Unlink, then link again. If Discord is your only sign-in method, add an email and password first so you are not locked out. Cancelling authorization links nothing; demo mode never links an identity.

What linking does

It records your Discord account against your LuaSecure profile so a Discord bot can match the two. If the operator turned on the extra options, linking can also add you to their Discord server and grant a verified role. It does not grant a paid plan or change license permissions, and LuaSecure never sees your Discord password.

Operator setup (server-side OAuth, bot-ready)

This is the recommended setup for running a bot. The client secret and bot token live only in the server environment — never in web/config.js.

  1. Create an application in the Discord Developer Portal and copy its Client ID and Client Secret.
  2. Under OAuth2 → Redirects, add https://luasecure.xyz/auth/discord/callback (use the matching origin for staging).
  3. Apply the 20261009_discord_profile.sql migration in Supabase so the Discord id can be stored on the profile.
  4. Set DISCORD_CLIENT_ID and DISCORD_CLIENT_SECRET in the server environment and redeploy.
  5. Optional, for the bot to auto-add members and roles: create a bot, set DISCORD_BOT_TOKEN, DISCORD_GUILD_ID, an optional DISCORD_VERIFIED_ROLE_ID, and add guilds.join to DISCORD_OAUTH_SCOPES. Invite the bot to the server and keep its role above any role it grants.

A bot looks a member up by their Discord id with the service-role key: select id, email, plan from profiles where discord_user_id = $1.

Alternative: Supabase identity linking

If the server OAuth variables are not set, the dashboard falls back to Supabase Auth identity linking. Enable the Discord provider and Manual Linking in Supabase, and allow https://luasecure.xyz/dashboard/overview?discord=return in its redirect list. This path also saves the verified Discord identity for the bot. Both paths require the Discord profile migration and the server database connection.

Troubleshooting

Check /bot/health: configured must be true. Set BOT_API_SECRET to the same value on the website and bot, and set BOT_OWNER_ID on the website to the owner’s LuaSecure profile UUID. A bot API error or an empty script list does not mean your Discord account is unlinked.

A provider-disabled or not-configured error needs operator configuration. A Discord account already linked to another LuaSecure user cannot be linked again; sign in to the correct account or use a different Discord account. A discord=setup result after linking means the database migration above still needs to be applied.

Official references: Discord OAuth2, Supabase Discord provider, and identity linking.