mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
change: prettier code
This commit is contained in:
committed by
GitHub Action
parent
a9e5ce01c9
commit
3878115640
+16
-22
@@ -18,15 +18,12 @@ export async function createBot(options: CreateBotOptions) {
|
||||
id: options.botId,
|
||||
applicationId: options.applicationId || options.botId,
|
||||
token: `Bot ${options.token}`,
|
||||
events: {dispatchRequirements: dispatchRequirements, ...options.events},
|
||||
intents: options.intents.reduce(
|
||||
(bits, next) => (bits |= DiscordGatewayIntents[next]),
|
||||
0
|
||||
),
|
||||
botGatewayData: options.botGatewayData || await getGatewayBot(),
|
||||
events: { dispatchRequirements: dispatchRequirements, ...options.events },
|
||||
intents: options.intents.reduce((bits, next) => (bits |= DiscordGatewayIntents[next]), 0),
|
||||
botGatewayData: options.botGatewayData || (await getGatewayBot()),
|
||||
isReady: false,
|
||||
rest: createRestManager(options.rest ? { token: options.token, ...options.rest} : { token: options.token})
|
||||
}
|
||||
rest: createRestManager(options.rest ? { token: options.token, ...options.rest } : { token: options.token }),
|
||||
};
|
||||
}
|
||||
|
||||
const bot = await createBot({
|
||||
@@ -34,14 +31,14 @@ const bot = await createBot({
|
||||
botId: 0n,
|
||||
events: createEventHandlers(),
|
||||
intents: [],
|
||||
})
|
||||
});
|
||||
|
||||
export function createEventHandlers(options?: Partial<EventHandlers>) {
|
||||
return {
|
||||
debug: () => undefined,
|
||||
// PROVIDED OPTIONS OVERRIDE EVERYTHING ABOVE
|
||||
...options
|
||||
}
|
||||
...options,
|
||||
};
|
||||
}
|
||||
|
||||
export interface CreateRestManagerOptions {
|
||||
@@ -58,7 +55,7 @@ export interface CreateRestManagerOptions {
|
||||
processRequest?: typeof processRequest;
|
||||
createRequestBody?: typeof createRequestBody;
|
||||
runMethod?: typeof runMethod;
|
||||
simplifyUrl?: typeof simplifyUrl
|
||||
simplifyUrl?: typeof simplifyUrl;
|
||||
}
|
||||
|
||||
export function createRestManager(options: CreateRestManagerOptions) {
|
||||
@@ -88,7 +85,7 @@ export function createRestManager(options: CreateRestManagerOptions) {
|
||||
createRequestBody: options.createRequestBody || createRequestBody,
|
||||
runMethod: options.runMethod || runMethod,
|
||||
simplifyUrl: options.simplifyUrl || simplifyUrl,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function startBot(bot: Bot) {
|
||||
@@ -96,13 +93,12 @@ export async function startBot(bot: Bot) {
|
||||
bot.rest = createRestManager({ token: bot.token });
|
||||
|
||||
// START WS
|
||||
bot.gateway = createGatewayManager()
|
||||
bot.gateway = createGatewayManager();
|
||||
}
|
||||
|
||||
export function stopBot(bot: Bot) {
|
||||
// STOP REST
|
||||
|
||||
// STOP WS
|
||||
// STOP REST
|
||||
// STOP WS
|
||||
}
|
||||
|
||||
export interface CreateBotOptions {
|
||||
@@ -122,14 +118,12 @@ export type CreatedBot = UnPromise<ReturnType<typeof createBot>>;
|
||||
export type Bot = CreatedBot & {
|
||||
rest: RestManager;
|
||||
gateway: GatewayManager;
|
||||
}
|
||||
};
|
||||
|
||||
export type RestManager = ReturnType<typeof createRestManager>;
|
||||
|
||||
export interface GatewayManager {
|
||||
|
||||
}
|
||||
export interface GatewayManager {}
|
||||
|
||||
export interface EventHandlers {
|
||||
debug: (text: string) => unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ export async function processQueue(rest: RestManager, id: string) {
|
||||
}
|
||||
|
||||
// IF A BUCKET EXISTS, CHECK THE BUCKET'S RATE LIMITS
|
||||
const bucketResetIn = queuedRequest.payload.bucketId ? rest.checkRateLimits(rest, queuedRequest.payload.bucketId) : false;
|
||||
const bucketResetIn = queuedRequest.payload.bucketId
|
||||
? rest.checkRateLimits(rest, queuedRequest.payload.bucketId)
|
||||
: false;
|
||||
// THIS BUCKET IS STILL RATELIMITED, RE-ADD TO QUEUE
|
||||
if (bucketResetIn) continue;
|
||||
|
||||
@@ -71,7 +73,9 @@ export async function processQueue(rest: RestManager, id: string) {
|
||||
}
|
||||
|
||||
if (response.status < 200 || response.status >= 400) {
|
||||
rest.debug(`[REST - httpError] Payload: ${JSON.stringify(queuedRequest.payload)} | Response: ${JSON.stringify(response)}`);
|
||||
rest.debug(
|
||||
`[REST - httpError] Payload: ${JSON.stringify(queuedRequest.payload)} | Response: ${JSON.stringify(response)}`
|
||||
);
|
||||
|
||||
let error = "REQUEST_UNKNOWN_ERROR";
|
||||
switch (response.status) {
|
||||
|
||||
@@ -9,7 +9,11 @@ export async function runMethod<T = any>(
|
||||
retryCount = 0,
|
||||
bucketId?: string
|
||||
): Promise<T> {
|
||||
rest.debug(`[REST - RequestCreate] Method: ${method} | URL: ${url} | Retry Count: ${retryCount} | Bucket ID: ${bucketId} | Body: ${JSON.stringify(body)}`)
|
||||
rest.debug(
|
||||
`[REST - RequestCreate] Method: ${method} | URL: ${url} | Retry Count: ${retryCount} | Bucket ID: ${bucketId} | Body: ${JSON.stringify(
|
||||
body
|
||||
)}`
|
||||
);
|
||||
|
||||
const errorStack = new Error("Location:");
|
||||
// @ts-ignore Breaks deno deploy. Luca said add tsignore until it's fixed
|
||||
|
||||
Reference in New Issue
Block a user