3.0.5 • Published 1 year ago

fero-dc v3.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

Introduction

Fero-DC is a discord.js library that does all the structures for you.

You get a completely different Client class that has a built-in command/event/slash command handler and other amazing features.

You also get a Command class and Event class for their respective handlers.

More will be added in the future.

Installation

NPM

npm install --save fero-dc

Yarn

yarn add fero-dc

Usage

Note: In TypeScript, when exporting commands and events, export them under:

export const command = new Command()

and

export const event = new Event()

Do not export as default.

Client

You will first need a .env file in your main directory and a config.json somewhere.

Main JS File

const { Client } = require("fero-dc");
const { join } = require("path");

const cwd = process.cwd();

new Client(
	{
		config: join(cwd, "src", "Data", "config.json"), // Path to your config file (use absolute paths)
		commands: join(cwd, "src", "Commands"), // Path to your commands directory
		events: join(cwd, "src", "Events") // Path to your events directory
	},
	{} /* Modules, anything you put in here will result inside the client (ex: { discord: require("discord.js") } -> client.discord is now the discord.js library)*/
);

Config JSON File

{
	"_comments": {
		"prefix": "The default prefix of the bot",
		"tokenName": "The name of the token variable in the .env file",
		"permissionData": "The permission data to check with when doing client.checkPermissions, basically set any key to an array of role IDs or permissions",
		"commandLoadedMessage": "Whether or not to print to the console that a command was loaded",
		"eventLoadedMessage": "Whether or not to print to the console that an event was loaded",
		"builtInHelpCommand": "The options for the built-in help command, can either be false or MessageEmbedOptions + slashCommand: boolean",
		"deleteUnusedSlashCommands": "Whether or not to delete slash commands that don't appear in the commands directory"
	},
	"prefix": "!",
	"tokenName": "TOKEN",
	"permissionData": { "MOD": ["ROLE ID"] },
	"commandLoadedMessage": true,
	"eventLoadedMessage": true,
	"builtInHelpCommand": { "slashCommand": true, "color": "RANDOM" },
	"deleteUnusedSlashCommands": false
}

ENV File

TOKEN = BOTTOKEN

Command

Create a JS file in your Commands directory (Allows 1 depth folder nesting)

Command JS File

const { Command } = require("fero-dc");

module.exports = new Command({
    name: "ping", // The name of the command
    description: "Shows the bot's ping", // The description of the command
    aliases: [], // The aliases (secondary names) of the command
    permissions: ["SEND_MESSAGES"], // The permissions required to use the command
    type: "BOTH", // The type of the command (BOTH, SLASH, TEXT) (tells the client if the command is a slash command or not)
    category: "utility", // The category of the command
    usage: "!ping <test: string>", // The way to use the command in Discord (A usage is already created with the args of the command, I don't recommend using this)
    args: [
        {
            name: "test",
            description: "This is a test",
            required: true,
            type: "string"
        }
    ], // The arguments to convert in the run function
    slashCommandOptions: [
        {
            name: "test",
            description: "This is a test",
            type: "STRING",
            required: true
        }
    ] // The options to register with the slash command
    },
    async (message, args, client, test) => {

        message.reply(test); // !ping testString -> bot replies "testString"

    } // The function that runs when the command is run
);

Event

Create a JS file in your Events directory (Allows 1 depth folder nesting)

Event JS File

const { Event } = require("fero-dc");

module.exports = new Event("messageCreate", async (client, message) => {
	const prefix = client.prefix(message.guild);
	if (
		message.author.bot ||
		!message.guild ||
		!prefix ||
		!message.content.startsWith(prefix)
	)
		return;

	const [cmd, ...args] = message.content.substring(prefix.length).split(/ +/);

	const command = client.commands.find(
		c =>
			c.name.toLowerCase() == cmd.toLowerCase() ||
			c.aliases.map(v => v.toLowerCase()).includes(cmd.toLowerCase())
	);

	if (!command) return message.reply(`${cmd} is not a valid command!`);

	const perm = client.checkPermissions(command.permissions, message.member);

	if (!perm)
		return message.reply(
			"You do not have the correct permissions to use this command!"
		);

	client.runCommand(command, message, args);
});
4.0.0-dev-21

1 year ago

4.0.0-dev-20

1 year ago

4.0.0-dev-18

1 year ago

4.0.0-dev-19

1 year ago

4.0.0-dev-16

1 year ago

4.0.0-dev-17

1 year ago

4.0.0-dev-14

1 year ago

4.0.0-dev-15

1 year ago

4.0.0-dev-12

1 year ago

4.0.0-dev-13

1 year ago

4.0.0-dev-10

1 year ago

4.0.0-dev-11

1 year ago

4.0.0-dev-9

1 year ago

4.0.0-dev-5

2 years ago

4.0.0-dev-6

2 years ago

4.0.0-dev-7

2 years ago

4.0.0-dev-8

2 years ago

4.0.0-dev-1

2 years ago

4.0.0-dev-2

2 years ago

4.0.0-dev-3

2 years ago

4.0.0-dev-4

2 years ago

3.0.4

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.8

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

2.0.0-beta

3 years ago

2.0.0-alpha

3 years ago

2.0.0-charlie

3 years ago

1.6.0

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.9

3 years ago

1.5.8

3 years ago

1.5.7

3 years ago

1.5.6

3 years ago

1.4.4

3 years ago

1.5.2

3 years ago

1.4.3

3 years ago

1.5.1

3 years ago

1.4.2

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago