1.0.27 • Published 3 years ago

easy-discordjs-framework v1.0.27

Weekly downloads
156
License
MIT
Repository
github
Last release
3 years ago

Framework

This module makes making a discord bot way easier! The module loads the commands and events without a command handler needed! The bot also runs the commands when executed.

Installing the bot

  1. Install module: npm install easy-discordjs-framework
  2. Make index.js, example:
const framework = require("easy-discordjs-framework");

const client = new framework({
  token: "TOKEN", // Bot token
  language: "NL", // NL/EN
  prefix: "!", // prefix => !help, !rank, ..
});
client.connect();
  1. Make commands folder with command file
  • Command template:
module.exports = {
  name: "example",
  category: "",
  aliases: ["ex"],
  description: "This is an example command",
  run: async (bot, message, args) => {
    message.reply("hey");
  },
};
  • Other way to add commands:
client.bind("example", {
  run: async (bot, message, args) => {
    message.reply("hey");
  },
});
  1. Make an events folder with an event
  • Event layout:
module.exports.name = "ready";
module.exports.run = async (client) => {
  console.log("I am online!");
};
  • Other way to add events:
client.observe("ready", () => {
  console.log("I am ready!");
});

Options

new framework({
  token: "TOKEN", // REQUIRED. Bot token
  language: "EN", // Language: NL/EN
  defaultPrefix: "!", // prefix: !help, !rank, ..
  config: {
    guildSettings: { prefix: "!" }, // Standard settings when bot joins a new guild
    userSettings: {}, // Standard settings when a new user uses the bot
  },
  igbots: true, // Ignore messages from bots
  status: "everyone", // Bot stauts
  statusType: "PLAYING", // Bot status type
});

Using custom functions

Command test.js (in commands folder)

Send embed with standard footer, embed color and timestamp

message.sendEmbed({ title: "Hello", desc: "Hey!" });

Sends the same embed as before, but you can edit this one!

let embed = message.embed().setTitle("Hello").setDescription("Hey!");
message.channel.send(embed);

Send an automatic error message

if (!args[0]) return message.error("You didn't give args!");

Send an automatic succes message

if (args[0]) message.succes("You did give args, good job!");

Find a member

let member = message.getMember(args[0]);
if (!member) return message.error("Can't find this member!");

Find a channel

let channel = message.getChannel(args[0]);
if (!channel) return message.error("Can't find this channel!");

Find a role

let role = message.getRole(args[0]);
if (!role) return message.error("Can't find this role!");

Check if a user is staff

if (!message.member.isStaff()) return message.error("You aren't staff!"); // Same with isMod and isAdmin

Using the database

The bot loads a database automatically. There are 2 different kinds:

User database

if (!message.author.settings.xp) message.author.settings.xp = 0;
message.author.settings.xp + 5;
message.author.updateDB(); // Update the user settings
message.succes(
  `You have gained 5 XP! You now have ${message.author.settings.xp} xp!`
);

Guild database

let prefix = message.guild.settings.prefix;
message.guild.settings.prefix = "?";
message.guild.updateDB(); // Update the guild settings

The db itself

let data = client.db.get("test"); // Get the data of value "test"
client.db.set("test", "hello"); // Set the value "test" to "hello"
client.db.delete("test"); // Delete the data of value "test"
1.0.26

3 years ago

1.0.27

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.22

3 years ago

1.0.23

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago