fix: client errors

This commit is contained in:
Skillz4Killz
2023-02-19 04:52:44 +00:00
parent 8adb744050
commit 96ecfccf2f
5 changed files with 457 additions and 635 deletions

View File

@@ -241,6 +241,8 @@ export class Client extends EventEmitter {
lastReconnectDelay: number = 0
/** The amount of times it has already tried to reconnect. */
reconnectAttempts: number = 0
/** The client user */
user?: ExtendedUser
constructor(token: string, options: ClientOptions) {
super()
@@ -264,6 +266,7 @@ export class Client extends EventEmitter {
maxResumeAttempts: options.maxResumeAttempts ?? Infinity,
intents: options.intents ?? 0,
autoreconnect: options.autoreconnect ?? true,
guildCreateTimeout: options.guildCreateTimeout ?? 2000,
reconnectDelay: options.reconnectDelay ?? ((lastDelay, attempts) => Math.pow(attempts + 1, 0.7) * 20000),
}
@@ -2313,6 +2316,11 @@ export interface ClientOptions {
intents?: GatewayIntents
/** Whether or not to automatically reconnect to gateway. */
autoreconnect?: boolean
/**
* How long in milliseconds to wait for a GUILD_CREATE before "ready" is fired. Increase this value if you notice missing guilds
* @default 2000
*/
guildCreateTimeout?: number
/** Handler to determine how many milliseconds to wait before reconnecting. */
reconnectDelay?: (lastDelay: number, attempts: number) => Promise<number> | number
}
@@ -2352,6 +2360,8 @@ export interface ParsedClientOptions {
intents: GatewayIntents
/** Whether or not to automatically reconnect to gateway. */
autoreconnect: boolean
/** How long in milliseconds to wait for a GUILD_CREATE before "ready" is fired. Increase this value if you notice missing guilds */
guildCreateTimeout: number
/** Handler to determine how many milliseconds to wait before reconnecting. */
reconnectDelay: (lastDelay: number, attempts: number) => Promise<number> | number
}

File diff suppressed because it is too large Load Diff

View File

@@ -977,7 +977,7 @@ export interface PartialEmoji {
// url: string;
// }
export interface RequestMembersPromise {
members: Member
members: Member[]
received: number
res: (value: Member[]) => void
timeout: number

View File

@@ -2,8 +2,6 @@ import { describe, it } from 'mocha'
describe('index.ts', () => {
it('will import without error', async () => {
try {
await import('../src/index.js')
} catch {}
})
})

View File

@@ -173,7 +173,7 @@ export interface StatusUpdate {
// /** Unix time (in milliseconds) of when the client went idle, or null if the client is not idle */
// since: number | null;
/** The user's activities */
activities: Camelize<DiscordActivity[]>
activities?: Camelize<Array<Omit<DiscordActivity, "created_at">>>
/** The user's new status */
status: keyof typeof PresenceStatus
// /** Whether or not the client is afk */