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

511
Vistas
Discord.js - ReferenceError: DiscordCollection is not defined

I was coding a bot using Discord.js, following Codelyon's code, and I am stuck with this error:

ReferenceError: DiscordCollection is not defined at Object.<anonymous>
const {Client, Intents, DiscordAPIError, Collection} = require('discord.js');

const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });

const prefix = '-';

const fs = require('fs');

client.commands = new DiscordCollection();

const commandFiles = fs.readdirSync(`./commands/`).filter(file => file.endsWith(`.js`));
for(const file of commandFiles){
    const command = require(`./commands/${file}`);

    client.commands.set(command.name,command);
}

client.once('ready', () => {
    console.log('Ceeby Is Online');
})

client.on('message', message => {
    if(!message.content.startsWith(prefix) || message.author.bot) return;

    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();

    if(command === 'ping'){
        client.commands.get('ping').execute(message, args);
    }
})
client.login('TOKEN')
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There are 2 common methods to import and use a libraries such as discord.js: importing the whole module or object destructuring- examples of both below. You seem to be trying to do both at the same time, you destructor the object but use Discord.Client and Discord.Collection instead of just Client and Collection.

Whole Module

const Discord = require('discord.js');
...
const client = new Discord.Client({ intents: ['GUILDS', 'GUILD_MESSAGES'] });
...
client.commands = new Discord.Collection();

Object Destructuring

const { Client, Collection, DiscordAPIError } = require('discord.js');
...
const client = new Client({ intents: ['GUILDS', 'GUILD_MESSAGES'] });
...
client.commands = new Collection();
about 4 years ago · Juan Pablo Isaza Denunciar
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