0

在此处输入图像描述

const fs = require('fs');
const path = require('path');
const {
   Client,
   Collection,
   Intents
} = require('discord.js');  
const chalk = require('chalk')
const config = require('./config.json');

const client = new Client({
    intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, 
Intents.FLAGS.GUILD_MEMBERS],
});

const Discord = require('discord.js');
client.discord = Discord;
client.config = config;

client.commands = new Collection();
const commandFiles = fs.readdirSync(path.resolve('G:\\Five_M\\txData\\ZAP-HostingESXPack_EBD469.base\\resources\\ticketbot','./commands')).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
   const command = require(`./commands/${file}`);
   client.commands.set(command.data.name, command);
};

const eventFiles = fs.readdirSync(path.resolve('G:\\Five_M\\txData\\ZAP-HostingESXPack_EBD469.base\\resources\\ticketbot', './events')).filter(file => file.endsWith('.js')); 

for (const file of eventFiles) {
   const event = require(`./events/${file}`);
   client.on(event.name, (...args) => event.execute(...args, client));
};

client.on('interactionCreate', async interaction => {
  if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);
if (!command) return;

try {
  await command.execute(interaction, client, config);
  } catch (error) {
     console.error(error);
     return interaction.reply({
    content: 'There was an error while executing this command!',
    ephemeral: true
    });
   };
});

client.login(require('./config.json').token);

[脚本:ticketbot]在资源ticketbot中加载脚本index.js时出错:SyntaxError:标识符'fs'已经被声明[脚本:ticketbot]堆栈:[脚本:ticketbot]语法错误:标识符'fs'已经被声明

需要有关此问题的帮助提及“fs 已被声明”

4

0 回答 0