Merge pull request #1897 from Disq-Code-Bot/fix/secret-key-option

Fix/secret key option
This commit is contained in:
ITOH
2022-01-18 20:40:22 +01:00
committed by GitHub
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -112,7 +112,7 @@ export function createBot(options: CreateBotOptions): Bot {
unrepliedInteractions: new Set<bigint>(),
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<EventHandlers>;
intents: (keyof typeof GatewayIntents)[];
botGatewayData?: GetGatewayBot;
+6
View File
@@ -35,6 +35,12 @@ export async function runMethod<T = any>(
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;
}