Spaces:
Runtime error

Brozy123 commited on
Commit
55b7f0e
·
verified ·
1 Parent(s): 0ac5285

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +3 -13
index.js CHANGED
@@ -94,18 +94,12 @@ const client = new Client({
94
  partials: [Partials.Message, Partials.Channel, Partials.Reaction],
95
  rest: {
96
  timeout: 120_000,
97
- agent: ultimateFix.dispatcher,
98
  retries: 3
99
- },
100
- ws: {
101
- agent: require('https').globalAgent,
102
- gateway: (process.env.DISCORD_BASE_URL ? process.env.DISCORD_BASE_URL.replace('http', 'ws') : undefined),
103
- compress: false // Disable compression for more stability over the proxy tunnel
104
  }
 
105
  });
106
 
107
  const DISCORD_ENDPOINTS = [
108
- (process.env.DISCORD_BASE_URL ? process.env.DISCORD_BASE_URL.replace(/\/$/, '') + '/api' : 'https://discord.com/api'),
109
  'https://discord.com/api',
110
  'https://canary.discord.com/api',
111
  'https://ptb.discord.com/api'
@@ -3592,9 +3586,8 @@ async function initialize() {
3592
  method: 'GET',
3593
  headers: {
3594
  'Authorization': `Bot ${TOKEN}`,
3595
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
3596
- },
3597
- dispatcher: ultimateFix.dispatcher
3598
  });
3599
 
3600
  if (response.statusCode === 200) testRes = { ok: true };
@@ -3609,10 +3602,7 @@ async function initialize() {
3609
  return;
3610
  } else if (testRes) {
3611
  console.log(`[SUCCESS] ✅ Connected via ${currentApi}`);
3612
- // Lock the bot to the tunnel
3613
  client.token = TOKEN;
3614
- client.options.rest.api = currentApi;
3615
- if (client.rest) client.rest.options.api = currentApi;
3616
  } else {
3617
  const errDetail = testError ? `${testError.status || 'TIMEOUT'} - ${testError.message}` : "Unknown Error";
3618
  console.warn(`[BLOCKED] ⚠️ ${currentApi} failed: ${errDetail}`);
 
94
  partials: [Partials.Message, Partials.Channel, Partials.Reaction],
95
  rest: {
96
  timeout: 120_000,
 
97
  retries: 3
 
 
 
 
 
98
  }
99
+ // ws: use discord.js defaults (no custom agent, no custom gateway, default compression)
100
  });
101
 
102
  const DISCORD_ENDPOINTS = [
 
103
  'https://discord.com/api',
104
  'https://canary.discord.com/api',
105
  'https://ptb.discord.com/api'
 
3586
  method: 'GET',
3587
  headers: {
3588
  'Authorization': `Bot ${TOKEN}`,
3589
+ 'User-Agent': 'DiscordBot (FriendlyBot, 4.0)'
3590
+ }
 
3591
  });
3592
 
3593
  if (response.statusCode === 200) testRes = { ok: true };
 
3602
  return;
3603
  } else if (testRes) {
3604
  console.log(`[SUCCESS] ✅ Connected via ${currentApi}`);
 
3605
  client.token = TOKEN;
 
 
3606
  } else {
3607
  const errDetail = testError ? `${testError.status || 'TIMEOUT'} - ${testError.message}` : "Unknown Error";
3608
  console.warn(`[BLOCKED] ⚠️ ${currentApi} failed: ${errDetail}`);