|
|
@ -11,9 +11,19 @@ const __dirname = path.dirname(__filename);
|
|
|
|
|
|
|
|
|
|
|
|
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
|
|
|
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
|
|
|
|
|
|
|
|
|
|
|
|
// Load commands from the commands folder
|
|
|
|
// Load commands
|
|
|
|
client.commands = new Collection();
|
|
|
|
client.commands = new Collection();
|
|
|
|
const commandsPath = path.join(__dirname, 'commands');
|
|
|
|
await loadCommandFromDir('fun');
|
|
|
|
|
|
|
|
await loadCommandFromDir('utility');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Load events
|
|
|
|
|
|
|
|
loadEventFromDir('client', client);
|
|
|
|
|
|
|
|
loadEventFromDir('process', process);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client.login(token);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function loadCommandFromDir(dir) {
|
|
|
|
|
|
|
|
const commandsPath = path.join(`${__dirname}/commands`, dir);
|
|
|
|
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
|
|
|
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
|
|
|
|
for (const file of commandFiles) {
|
|
|
|
for (const file of commandFiles) {
|
|
|
@ -23,37 +33,21 @@ for (const file of commandFiles) {
|
|
|
|
|
|
|
|
|
|
|
|
client.commands.set(command.data.name, command);
|
|
|
|
client.commands.set(command.data.name, command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Load client events from the events folder
|
|
|
|
|
|
|
|
const clientEventsPath = path.join(__dirname, 'events/client');
|
|
|
|
|
|
|
|
const clientEventFiles = fs.readdirSync(clientEventsPath).filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const file of clientEventFiles) {
|
|
|
|
|
|
|
|
const filePath = path.join(clientEventsPath, file);
|
|
|
|
|
|
|
|
let event = await import(filePath);
|
|
|
|
|
|
|
|
event = event.default;
|
|
|
|
|
|
|
|
if (event.once) {
|
|
|
|
|
|
|
|
client.once(event.name, (...args) => event.execute(...args));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
client.on(event.name, (...args) => event.execute(...args));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Load process events from the events folder
|
|
|
|
async function loadEventFromDir(dir, listener) {
|
|
|
|
const processEventsPath = path.join(__dirname, 'events/process');
|
|
|
|
const eventsPath = path.join(`${__dirname}/events`, dir);
|
|
|
|
const processEventFiles = fs.readdirSync(processEventsPath).filter(file => file.endsWith('.js'));
|
|
|
|
const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'));
|
|
|
|
|
|
|
|
|
|
|
|
for (const file of processEventFiles) {
|
|
|
|
for (const file of eventFiles) {
|
|
|
|
const filePath = path.join(processEventsPath, file);
|
|
|
|
const filePath = path.join(eventsPath, file);
|
|
|
|
let event = await import(filePath);
|
|
|
|
let event = await import(filePath);
|
|
|
|
event = event.default;
|
|
|
|
event = event.default;
|
|
|
|
if (event.once) {
|
|
|
|
if (event.once) {
|
|
|
|
process.once(event.name, (...args) => event.execute(...args));
|
|
|
|
listener.once(event.name, (...args) => event.execute(...args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
process.on(event.name, (...args) => event.execute(...args));
|
|
|
|
listener.on(event.name, (...args) => event.execute(...args));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
client.login(token);
|
|
|
|
|
|
|
|