Files
discordeno/helpers/misc/getGatewayBot.ts
2022-02-11 09:49:53 +00:00

19 lines
724 B
TypeScript

import type { GetGatewayBot } from "../../types/gateway/getGatewayBot.ts";
import type { Bot } from "../../bot.ts";
/** Get the bots Gateway metadata that can help during the operation of large or sharded bots. */
export async function getGatewayBot(bot: Bot): Promise<GetGatewayBot> {
const result = await bot.rest.runMethod<GetGatewayBot>(bot.rest, "get", bot.constants.endpoints.GATEWAY_BOT);
return {
url: result.url,
shards: result.shards,
sessionStartLimit: {
total: result.session_start_limit.total,
remaining: result.session_start_limit.remaining,
resetAfter: result.session_start_limit.reset_after,
maxConcurrency: result.session_start_limit.max_concurrency,
},
};
}