Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
<ShardingManager>.spawn() being called in a loop

It seems that my <ShardingManager>.spawn() is calling itself in a loop and I'm not sure why. I followed the getting started article on the Discord.js guide website. My Discord.js version is 13.0.6. I have also tried using a different Discord application token but that didn't help either.

It looks as if index.js is being executed multiple times, and I'm not sure why.

Here's my setup:

index.ts:

import { Application } from './Application';

export const application = new Application();
application.initSharding();

Application.ts:

import { ShardingManager } from 'discord.js';
import dotenv from 'dotenv';
import path from 'path';

export class Application {
    public async initSharding() {
        const shardingManager = new ShardingManager('./build/Shard.js', {
            token: process.env.DISCORD_TOKEN,
        });

        shardingManager.on('shardCreate', shard => {
            console.log(`[SHARDING MANAGER] LAUNCHED SHARD ${shard.id}`);
        });

        await shardingManager.spawn().catch(reason => console.log(reason));
    }

    constructor() {
        dotenv.config({ path: path.resolve(__dirname, '../variables.env') });
    }
}

Shard.ts:

import { Client, Intents } from 'discord.js';
import { application } from '.';
import { Utils } from './Utils';

export class Shard {
    private _client: Client;

    constructor() {
        this._client = new Client({
            intents: [Intents.FLAGS.GUILDS],
        });

        this._client.login(process.env.DISCORD_TOKEN).catch(reason => console.log(reason));
    }
}

new Shard();

I eventually get the following error:

RESPONSE {
  SIZE: 0,
  TIMEOUT: 0,
  [SYMBOL(BODY INTERNALS)]: {
    BODY: PASSTHROUGH {
      _READABLESTATE: [READABLESTATE],  
      _EVENTS: [OBJECT: NULL PROTOTYPE],
      _EVENTSCOUNT: 2,
      _MAXLISTENERS: UNDEFINED,
      _WRITABLESTATE: [WRITABLESTATE],  
      ALLOWHALFOPEN: TRUE,
      [SYMBOL(KCAPTURE)]: FALSE,        
      [SYMBOL(KCALLBACK)]: NULL
    },
    DISTURBED: FALSE,
    ERROR: NULL
  },
  [SYMBOL(RESPONSE INTERNALS)]: {
    URL: 'HTTPS://DISCORD.COM/API/V9/GATEWAY/BOT',
    STATUS: 429,
    STATUSTEXT: 'TOO MANY REQUESTS',
    HEADERS: HEADERS { [SYMBOL(MAP)]: [OBJECT: NULL PROTOTYPE] },
    COUNTER: 0
  }
}

Any help is appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!