fix: gateway manager options

This commit is contained in:
Marcos Susaña 2023-06-30 20:06:05 -04:00
parent e535108956
commit 2e9fb74c16
2 changed files with 5 additions and 6 deletions

View File

@ -1,12 +1,10 @@
export const GatewayManagerDefaultOptions = {
compress: false,
intents: 0,
properties: {
os: process.platform,
browser: 'Biscuit',
device: 'Biscuit'
},
url: 'wss://gateway.discord.gg',
version: 10,
totalShards: 1,
lastShardId: 0,

View File

@ -13,12 +13,13 @@ export class GatewayManager {
cache: Collection<string, GatewayMemberRequest> | null = null;
options: Required<CreateGatewayManagerOptions>;
logger: Logger;
constructor(options: CreateGatewayManagerOptions) {
constructor({ connection, ...options }: CreateGatewayManagerOptions) {
this.options = Options<Required<CreateGatewayManagerOptions>>(GatewayManagerDefaultOptions, {
...options,
lastShardId:
options.lastShardId ?? (options.totalShards ? options.totalShards - 1 : options.connection ? options.connection.shards - 1 : 0)
lastShardId: options.lastShardId ?? (options.totalShards ? options.totalShards - 1 : connection ? connection.shards - 1 : 0)
});
this.options.connection = connection;
if (this.options.cache) this.cache = new Collection();
this.logger = new Logger({
name: '[GatewayManager]',
@ -114,7 +115,7 @@ export class GatewayManager {
id: shardId,
connection: {
intents: this.options.intents,
url: this.options.url,
url: this.options.connection.url,
version: this.options.version,
token: this.options.token,
totalShards: this.options.totalShards,