1.2.7 • Published 2 years ago
slzpackage v1.2.7
Intro
slzpackage is a package for discord.js v13, slzpackage includes commands and events handlers, it will be updated regularly with new features.
Installation
npm i slzpackage
Index.js
In the index.js file
['name-file-for-handler'].forEach(handler => {
require(`./name-folder-for-handlers/${handler}`)(client);
});
Handler File
You will need the fs package
const fs = require('fs');
module.exports = async (client) => {
//Events
fs.readdirSync('./events')
.filter(file => file.endsWith(".js"))
.forEach(file => {
const event = require(`../events/${file}`)
client.on(event.event, event.run)
})
//Commands
const subFolders = fs.readdirSync('./commands')
for (const category of subFolders) {
const commandsFiles = fs.readdirSync(`./commands/${category}`).filter(file => file.endsWith('.js'))
for (const commandFile of commandsFiles) {
const command = require(`../commands/${category}/${commandFile}`)
client.commands.set(command.name, command)
if (command.aliases && command.aliases.length > 0) {
command.aliases.forEach(alias => client.aliases.set(alias, command))
}
}
}
}
Test Event
const { Event } = require("slzpackage")
module.exports = new Event("messageCreate", (message) => {
if (message.content === 'ping') {
message.reply('pong');
}
})
Test Command
const { Command } = require("slzpackage");
module.exports = new Command({
name: 'ping',
dirname: __dirname,
run: async ({client, message, args}) => {
message.reply("pong!")
},
});