fix(WS): Get gateway data

This commit is contained in:
Cinnamon 2022-07-02 09:52:24 +07:00
parent 6d90b1610e
commit b672427756
3 changed files with 15 additions and 0 deletions

View File

@ -127,6 +127,8 @@ class WebSocketManager extends EventEmitter {
*/
async connect() {
const invalidToken = new Error(WSCodes[4004]);
/*
BOT
const {
url: gatewayURL,
shards: recommendedShards,
@ -134,6 +136,17 @@ class WebSocketManager extends EventEmitter {
} = await this.client.api.gateway.bot.get().catch(error => {
throw error.httpStatus === 401 ? invalidToken : error;
});
*/
const { url: gatewayURL } = await this.client.api.gateway.get({ auth: false }).catch(error => {
// Never throw error :v
throw error.httpStatus === 401 ? invalidToken : error;
});
const recommendedShards = 1;
const sessionStartLimit = {
total: 1000000000,
remaining: 1000000000,
};
const { total, remaining } = sessionStartLimit;

View File

@ -175,6 +175,7 @@ exports.Endpoints = {
invite: (root, code, eventId) => (eventId ? `${root}/${code}?event=${eventId}` : `${root}/${code}`),
scheduledEvent: (root, guildId, eventId) => `${root}/${guildId}/${eventId}`,
botGateway: '/gateway/bot',
userGateway: '/gateway',
};
/**

1
typings/index.d.ts vendored
View File

@ -3066,6 +3066,7 @@ export const Constants: {
};
Endpoints: {
botGateway: string;
userGateway: string;
invite: (root: string, code: string, eventId?: Snowflake) => string;
scheduledEvent: (root: string, guildId: Snowflake, eventId: Snowflake) => string;
CDN: (root: string) => {