无法读取属性'forEach'的内容,是我尝试运行我的机器人并且不确定如何解决它时遇到的错误...我已经尝试过查找,但是没有运气,对于discod.js来说,这是一个相当新的东西和Java脚本,因此所有帮助都将不胜枚举!
代码
const { config } = require('dotenv');
const client = new Client({
disableEveryone: true
});
client.commands = new Collection();
client.aliases = new Collection();
config({
path: __dirname + "/.env"
})
["command"].forEach(handler => {
});(handler => {
require(`./handler/${handler}`)(client);
});
client.on("ready", () => {
console.log(`Hi, ${client.user.username} is now online!`);
client.user.setPresence({
status: "online",
game: {
name: "me getting developed",
type: "WATCHING"
}
});
});
client.on("message", async message => {
const prefix = "_";
if (message.author.bot) return;
if (!message.guild) return;
if (!message.content.startsWith(prefix)) return;
if (!message.member) message.member = await message.guild.fetchMember(message);
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const cmd = args.shift().toLowerCase();
if (cmd.length === 0) return;
let command = client.commands.get(cmd);
if (!command) command = client.commands.get(client.aliases.get(cmd));
if (command)
command.run(client, message, args);
});
client.login(process.env.TOKEN);