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