Enhance guild management features in the owner panel
- Updated the guilds API to support searching by both guild name and ID, improving user experience. - Increased the number of guilds retrieved from the database from 100 to 200 for better visibility. - Implemented invite creation functionality, allowing owners to generate invites directly from the guild management interface. - Enhanced the UI to display guild names, icons, and member counts, providing a more informative overview. - Updated localization files to reflect new search capabilities and invite-related messages in both English and German.
This commit is contained in:
@@ -6,14 +6,26 @@ import { redis } from './redis';
|
||||
const DISCORD_API_BASE = 'https://discord.com/api/v10';
|
||||
const CACHE_TTL_SECONDS = 60;
|
||||
|
||||
async function discordBotFetch<T>(path: string): Promise<T> {
|
||||
export async function discordBotFetch<T>(
|
||||
path: string,
|
||||
init?: { method?: string; body?: unknown }
|
||||
): Promise<T> {
|
||||
const method = init?.method ?? 'GET';
|
||||
const response = await fetch(`${DISCORD_API_BASE}${path}`, {
|
||||
headers: { Authorization: `Bot ${env.BOT_TOKEN}` },
|
||||
method,
|
||||
headers: {
|
||||
Authorization: `Bot ${env.BOT_TOKEN}`,
|
||||
...(init?.body !== undefined ? { 'Content-Type': 'application/json' } : {})
|
||||
},
|
||||
body: init?.body !== undefined ? JSON.stringify(init.body) : undefined,
|
||||
cache: 'no-store'
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Discord API request to ${path} failed with status ${response.status}`);
|
||||
}
|
||||
if (response.status === 204) {
|
||||
return undefined as T;
|
||||
}
|
||||
return (await response.json()) as T;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user