Enhance Discord integration by adding optional bot permissions in environment files and updating the dashboard to include an "Add Bot to your Server" button. Refactor authentication logic to handle token refresh and improve error handling for Discord sessions. Update placeholder text for better clarity in the search input field.
This commit is contained in:
21
dashboard/lib/discord-invite.ts
Normal file
21
dashboard/lib/discord-invite.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Discord bot invite URL helpers.
|
||||
*/
|
||||
const DEFAULT_PERMISSIONS = "8"; // Administrator (Discord invite UI still shows the checklist)
|
||||
|
||||
export function getBotInviteUrl(clientId?: string | null): string | null {
|
||||
const id =
|
||||
(clientId || "").trim() ||
|
||||
(process.env.DISCORD_CLIENT_ID || "").trim() ||
|
||||
(process.env.NEXT_PUBLIC_DISCORD_CLIENT_ID || "").trim();
|
||||
|
||||
if (!id) return null;
|
||||
|
||||
const params = new URLSearchParams({
|
||||
client_id: id,
|
||||
permissions: process.env.DISCORD_BOT_PERMISSIONS?.trim() || DEFAULT_PERMISSIONS,
|
||||
scope: "bot applications.commands",
|
||||
});
|
||||
|
||||
return `https://discord.com/oauth2/authorize?${params.toString()}`;
|
||||
}
|
||||
Reference in New Issue
Block a user