Brozy123 commited on
Commit
609e85d
·
verified ·
1 Parent(s): ae6debc

Update bot.js

Browse files
Files changed (1) hide show
  1. bot.js +22 -1
bot.js CHANGED
@@ -1,13 +1,34 @@
1
  "use strict";
2
  const { Client, GatewayIntentBits, MessageFlags, EmbedBuilder } = require("discord.js");
 
3
  const db = require("./db");
4
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  const client = new Client({
6
  intents: [
7
  GatewayIntentBits.Guilds,
8
  GatewayIntentBits.GuildMessages,
9
  GatewayIntentBits.MessageContent
10
- ]
 
 
 
 
 
 
 
 
11
  });
12
 
13
  client.once("ready", () => {
 
1
  "use strict";
2
  const { Client, GatewayIntentBits, MessageFlags, EmbedBuilder } = require("discord.js");
3
+ const { Agent } = require("undici");
4
  const db = require("./db");
5
 
6
+ // Configure a robust network agent with longer timeouts and specific DNS
7
+ const botAgent = new Agent({
8
+ connect: {
9
+ timeout: 15000, // Increase connect timeout to 15s
10
+ keepAlive: true,
11
+ keepAliveTimeout: 30000,
12
+ },
13
+ bodyTimeout: 0, // Prevent body timeout issues on slow networks
14
+ headersTimeout: 15000,
15
+ requestTimeout: 15000,
16
+ });
17
+
18
  const client = new Client({
19
  intents: [
20
  GatewayIntentBits.Guilds,
21
  GatewayIntentBits.GuildMessages,
22
  GatewayIntentBits.MessageContent
23
+ ],
24
+ rest: {
25
+ agent: botAgent,
26
+ timeout: 15000,
27
+ retries: 5, // More retries for flaky networks
28
+ },
29
+ ws: {
30
+ large_threshold: 50, // Reduce initial load
31
+ }
32
  });
33
 
34
  client.once("ready", () => {