TypeError:集合不是构造函数

时间:2020-05-08 07:10:18

标签: javascript discord discord.js

const Discord = require('discord.js'); 
const Collection = require('discord.js'); 
const Client = require('discord.js'); 
const fs = require('fs');
const bot = new Discord.Client({
  disableEveryone: true
});
bot.commands = new Collection();
bot.aliases = new Collection();

如果这还不够,请告诉我,我会发送更多,但错误在于这些行。谢谢。

1 个答案:

答案 0 :(得分:1)

您没有正确导入discord.js。

完全导入discord.js并通过它访问Collection()

const Discord = require ('discord.js')

bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection()

或仅导入您需要的内容:

const { Client, Collection } = require ('discord.js')

bot.commands = new Collection();
bot.aliases = new Collection()