so I'm working on branching off from basic commands to creating an advanced command handler and I'm following some youtube videos and guides, but I seem to be stuck. I'm getting an error that says Discord.Collections is not a constructor and I've looked everywhere and can't seem to find the answer to my problem so I thought I'd ask you guys for some help.
const { Client, Intents } = require('discord.js');
const { MessageEmbed } = require('discord.js')
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const prefix = '-';
const fs = require('fs');
const Discord = require('discord.js');
//Try to debug later
client.commands = new Discord.Collections();
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);
}
That's the code I have so far for it and in most forum it seems like it checks out, but I'm following an old video so maybe discord.js updated it to a new syntax or phrase along those lines? All help would be appreciated!
It's Collection without the 's'. Also you should clean up your imports since you seem to be importing the same module three times.
const { Client, Intents, MessageEmbed, Collection } = require('discord.js');
...
client.commands = new Collection();