diff --git a/src/bot.ts b/src/bot.ts index 9aeedc214..2b7c0aa53 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -112,7 +112,7 @@ export function createBot(options: CreateBotOptions): Bot { unrepliedInteractions: new Set(), fetchAllMembersProcessingRequests: new Map(), }, - rest: createRestManager({ token: options.token, debug: options.events.debug }), + rest: createRestManager({ token: options.token, debug: options.events.debug, secretKey: options.secretKey ?? undefined }), } as Bot; bot.helpers = createHelpers(bot, options.helpers ?? {}); @@ -399,6 +399,7 @@ export interface CreateBotOptions { token: string; botId: bigint; applicationId?: bigint; + secretKey?: string; events: Partial; intents: (keyof typeof GatewayIntents)[]; botGatewayData?: GetGatewayBot; diff --git a/src/rest/runMethod.ts b/src/rest/runMethod.ts index e20e9efbd..9a7c8801d 100644 --- a/src/rest/runMethod.ts +++ b/src/rest/runMethod.ts @@ -35,6 +35,12 @@ export async function runMethod( throw errorStack; }); + if (!result.ok) { + errorStack.message = result.statusText as Error['message']; + console.error(`Error: ${errorStack.message}`); + throw errorStack; + } + return result.status !== 204 ? await result.json() : undefined; }