Brozy123 commited on
Commit
93a5458
·
verified ·
1 Parent(s): faf81ad

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +18 -0
index.js CHANGED
@@ -1,4 +1,6 @@
1
  require('dotenv').config();
 
 
2
  const { Client, GatewayIntentBits, Partials, Collection, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, UserSelectMenuBuilder, ChannelSelectMenuBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ComponentType, MessageFlags, ChannelType } = require('discord.js');
3
  const storage = require('./storage');
4
  const roleStorage = require('./roleStorage');
@@ -13,6 +15,22 @@ const { createProfileAttachment } = require('./profileRenderer');
13
  const USE_NETWORK_HIJACK = process.env.ENABLE_NETWORK_HIJACK === 'true';
14
  if (USE_NETWORK_HIJACK) {
15
  networkFix.applyAdvancedFixes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  }
17
 
18
  console.log(`[SYSTEM] Starting FriendlyBot v4.0 (Watchdog Relaxed: ${new Date().toISOString()})`);
 
1
  require('dotenv').config();
2
+ const dns = require('dns');
3
+ const { Agent, setGlobalDispatcher } = require('undici');
4
  const { Client, GatewayIntentBits, Partials, Collection, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, UserSelectMenuBuilder, ChannelSelectMenuBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ComponentType, MessageFlags, ChannelType } = require('discord.js');
5
  const storage = require('./storage');
6
  const roleStorage = require('./roleStorage');
 
15
  const USE_NETWORK_HIJACK = process.env.ENABLE_NETWORK_HIJACK === 'true';
16
  if (USE_NETWORK_HIJACK) {
17
  networkFix.applyAdvancedFixes();
18
+ } else {
19
+ // Safe network tuning for HF/containers without hostname rewriting.
20
+ try {
21
+ if (dns.setDefaultResultOrder) dns.setDefaultResultOrder('ipv4first');
22
+ const safeAgent = new Agent({
23
+ connect: {
24
+ timeout: 30000,
25
+ family: 4
26
+ },
27
+ pipelining: 1,
28
+ keepAliveTimeout: 60000
29
+ });
30
+ setGlobalDispatcher(safeAgent);
31
+ } catch (e) {
32
+ console.warn('[NETWORK] Safe dispatcher setup skipped:', e.message);
33
+ }
34
  }
35
 
36
  console.log(`[SYSTEM] Starting FriendlyBot v4.0 (Watchdog Relaxed: ${new Date().toISOString()})`);