Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
<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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda