refactor: Add type annotations for response objects in API request handling
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
Vercel Production Deployment / Deploy-Production (push) Successful in 1m32s

This commit is contained in:
2025-10-16 13:21:01 +02:00
parent bbf3725acf
commit 968a843120
5 changed files with 22 additions and 10 deletions

View File

@@ -19,12 +19,16 @@ export class DiscordRateLimiter {
public async request<T>(path: string, options: RequestInit = {}): Promise<T> {
const url = `${this.baseUrl}${path}`;
const headers = {
const headers: Record<string, string> = {
'Authorization': `Bot ${this.botToken}`,
'Content-Type': 'application/json',
...options.headers,
...(options.headers as Record<string, string>),
};
// Only set Content-Type to application/json if body is a string and not explicitly set
if (typeof options.body === 'string' && !('Content-Type' in headers)) {
headers['Content-Type'] = 'application/json';
}
const response = await fetch(url, { ...options, headers });
if (response.status === 429) {