mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
feat(rest): use Agent with higher connect timeout (#8679)
* feat(rest): use Agent with higher connect timeout * chore: lint * chore: I'm an idiot Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import process from 'node:process';
|
import process from 'node:process';
|
||||||
import { APIVersion } from 'discord-api-types/v10';
|
import { APIVersion } from 'discord-api-types/v10';
|
||||||
import { getGlobalDispatcher } from 'undici';
|
import { Agent } from 'undici';
|
||||||
import type { RESTOptions } from '../REST.js';
|
import type { RESTOptions } from '../REST.js';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||||||
const Package = require('../../../package.json');
|
const Package = require('../../../package.json');
|
||||||
@@ -9,7 +9,11 @@ export const DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.vers
|
|||||||
|
|
||||||
export const DefaultRestOptions: Required<RESTOptions> = {
|
export const DefaultRestOptions: Required<RESTOptions> = {
|
||||||
get agent() {
|
get agent() {
|
||||||
return getGlobalDispatcher();
|
return new Agent({
|
||||||
|
connect: {
|
||||||
|
timeout: 30_000,
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
api: 'https://discord.com/api',
|
api: 'https://discord.com/api',
|
||||||
authPrefix: 'Bot',
|
authPrefix: 'Bot',
|
||||||
|
|||||||
Reference in New Issue
Block a user