5.5.0 • Published 3 years ago

discord-configured v5.5.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Features

  • 🔥Auto file update on save
  • 💨Highly performant
  • 💥Improved and added more functionality to Discord.js
  • 🚫Easy to understand errors
  • 💬Custom embed / attachments generators
  • 📨Custom command-handler
  • 🔰Custom event listeners
  • 🛑Anti-swear (around 155 swear words blocked)
  • 💾database system
  • 🎁giveaway system
  • 💼Detailed TTY logging system
  • 📋Message Attachment Download System
  • 📌Other easy to use functions!

Install

$ npm install discord-configured

Usage

To start off, you need to require the discord-configured node module. (When you install it, it comes with discord.js)

Once you have required it in the code, you need to initiate it with the init function, there are two types of initiation: advanced (Discord.init({})) or automatic (Discord.auto_init()) See Initiate code

Code Usage

To initiate the bot using advanced configurations:

Learn more about the advanced initiation properties at Advanced initiation properties

const Discord = require('discord-configured');

Discord.init({ // Initiate Bot
    token: "Your token", // Input your Discord bots token (NON-OPTIONAL)
    prefix: "!", // PCustom bot message prefix (NON-OPTIONAL)
    activity: 'Bot activity', // Custom bot activity (OPTIONAL)
    status: 'online', // Custom bot status (OPTIONAL) ['online', 'dnd', 'idle', 'offline']
    activityType: 'playing', // Custom bot activity type (OPTIONAL) ['playing', 'watching', 'listening']
    logs: true, // Show logs for Discord-configured actions (BOOLEAN) very recommended
    autoActivity: false, // GENERATES its own bot activity, status & activity type (BOOLEAN) NOTE: this overwrites your bot activity, status and activityType
    baseEmbedColor: "BLUE", // Default embed color, used when the custom embed generator is called (NON-OPTIONAL)
    errorEmbedColor: "RED",// Default error embed color, used when the custom error embed generator is called (NON-OPTIONAL)
    antiSwear: true, // toggles anti-swear functionality
    antiSwearMessage: "Please do not swear in this server!" // If a swear word is caught, then this message will be sent
    deleteSwearMessages: true, // If a swear word is caught, the message will be deleted
})

To initiate the bot using automatic configurations:

const Discord = require('discord-configured');

Discord.auto_init("Your token") // All the properties shown in the advanced version will be auto selected.

<h1> </h1>

## Discord-configured command-handler
> Our built-in command handler makes coding Discord bot way easyer
NOTE: Just chill out and let us do the work.
```js
- index.js
Discord.commandHandler({ 
    directory: "./commands", // The directory to your commands folder.
    includeCommand: true, // Include the "command" variable to your command handler's files.
    includeArgs: true, // Include the "args" variable to your command handler's files.
    includeMessage: true, // Include the "message" variable to your command handler's files.
    includeClient: true,  // Include the "cient" variable to your command handler's files.
    others: { // Include other custom variables.
        fs: require('fs') // Requires a custom node-module called fs
    }
})

ping command - a command handler file example:

- ping.js
module.exports.command = "ping"
module.exports.aliases = ["ws", 'hello?']
module.exports.run = function({
    command,
    args,
    message,
    client,
    fs
}) {
    message.reply('PONG!');
}

Discord-Configured comes with more advanced event listeners

NOTE: All default discord.js liseners are in Discord.events as well, these are just some example custom liseners.

Discord.events.once('started', time => { 
    /*
    Called when the Discord.init is finised applying data; 
    variables:
    - time = The time it took to finish the Discord.init in seconds
    */
    console.log(`Discord init finished in ${time}s`); 
})

Discord.events.once('ready', (time, options) => {  
    /*
    Called when the bot has started;
    variables:
    - time = The time it took to finish the bot in seconds
    - options: {
        prefix: bot prefix,
        activity: bot activity,
        status: bot status,
        ID: bot ID,
        username: bot username
    }
    */
    console.log(`bot has started!\nTook ${time}s to start`);
})

Discord.events.on('message', (message, data) => {
    /*
    Called when a message has been sent;
    variables:
    - message = The default message object from discord.js
    - data: {
        command: The command from message.content
        args: The args from message.content 
        embeds: any embeds from message.embeds
    }
    */
    if (data.command === "ping") message.channel.send('pong!')
})

Discord.events.on('commandHandler', info => {
    /*
    Called when a command was found in any of the commmand handlers files;
    variables:
    - info: {
        command: Command-handler's command
        aliases: Command-handler's aliases
        file: File name and extension
        directory: Directory to the command handler's file
        path: Direct path to the command handler's file
        fileSize: filesize of the command-handler's file
    }
    */
    console.log(`Command-handler's file used, FILE:\n`, info);
})

Discord-Configured comes with other custom function

Custom embed generator

        const embed = Discord.embed({ // NOTE: you do not need to add all these options
            color: "GREEN", // If not inputed, it will go for your default option, defined in the Discord.init.baseEmbedColor
            title: "This the title of this test embed!",
            titleURL: "https://url-for-the-title.png",
            authorName: "Author name",
            authorIcon: "https://author-icon-url.png",
            autoAuthor: message.author,
            /*
            ^ If you add this, then the author name and author icon will be replaced with the value you inputed's .username and .avatarURL(),
            in the case: message.author.username and message.author.avatarURL()
            */
            authorURL: "URL", // adds a url to the author's username, making the author's username a hyperlink
            description: "This is a random description", 
            timeStamp: true, // NOTE: this value must be a boolean
            fields: [],
            footer: "This is a test footer",
            footerIcon: "https://footer-icon-url.png",
            image: "https://image.png",
            thumbnail: "https://thumbnail.png",
            files: [] // add an atachment of files.
        })

        message.channel.send(embed) // Send your completly custom embed, with anti-pipe protection.
    

})

FAQ

How will this benifit you?

his API comes with built-in functionalitys like checking for errors, easy to use funcitions and even a built-in command handler making your life way easyer.

Any proof?

Yes, here is a before and after peace of code showing that more then 50% of code was not needed using this api.

BEFORE (20 lines of code, excluding comments)

const Discord = require('discord.js');
const client = new Discord.Client();
client.login('My token 123');
client.once('ready', () => {
    console.log('Bot started');
    client.user.setStatus('online');
    client.user.setActivity('!help for help');
})
const prefix = "!"
client.on('message', message => {
    const args = message.content.slice(prefix.length).split(/ +/g);
    const command = args.shift().toLowerCase()
    if (command === 'ping') {
        const embed = new Discord.MessageEmbed()
            .setColor('GREEN')
            .setTitle('PONG!')
            .setDescription("Yes, i am alive...")
        message.channel.send(embed)
    }
})
/*
Other Functionalitys thats running in the background:
- none
*/

AFTER (6 lines of code, excluding comments)

const Discord = require('discord-configured');
Discord.auto_init("My Token 123");
Discord.events.once('ready', (time, options) => console.log(`${options.username} has started!\nTook ${time}s to start`))
Discord.events.on('message', (message, data) => {
    if (Discord.isCmd(data, 'ping')) message.channel.send(Discord.embed({color: "GREEN", title: "PONG!", description: "Yes, i am alive..."}))
})
/*
Other Functionalitys thats running in the background:
- anti-swear (initiated at line: 2)
- auto prefix(initiated at line: 2)
- Discord-Configured auto logging actions to the console (initiated at line: 2)
- Check if message is command (initiated at line: 5)
- Generate Embed (initiated at line: 5)
- Auto presence (initiated at line: 2)
*/

Advanced Initiate Object properties

All the properties in the advanced Discord.init function.

• token

TYPE: String

Optional: false

Default: none

Info: Input your Discord bots token

Example: "A1B2C3"

• activity:

TYPE: String

Optional: true

Default: none

Info: Input your Discord bots token [Discord Developers portal]

Example: "Help: !help"

• prefix:

TYPE: String

Optional: false

Default: none

Info: Custom bot message prefix

Example: "!"

• status:

TYPE: String

Optional: true

Default: online

Info: Custom bot status

Example: "dnd" Options: 'online', 'dnd', 'idle', 'offline'

• activityType:

TYPE: String

Optional: true

Default: PLAYING

Info: Custom bot activity type

Example: "WATCHING" 'playing', 'watching', 'listening'

• logs:

TYPE: Boolean

Optional: true

Default: true

Info: Show logs for Discord-configured actions

Example: true true, false

• autoActivity:

TYPE: Boolean

Optional: true

Default: false

Info: generates its own bot activity, status & activity type NOTE: this overwrites your bot activity, status and activityType

Example: true true, false

• baseEmbedColor:

TYPE: String

Optional: false

Default: none

Info: Default embed color, used when the custom embed generator (Custom Embed Generator) is called

Example: "#FFFFFF"

• errorEmbedColor:

TYPE: String

Optional: false

Default: RED

Info: Default error embed color, used when the custom error embed generator is called

Example: "RED"

• antiSwear:

TYPE: Boolean

Optional: true

Default: true

Info: toggles anti-swear functionality

Example: true

• antiSwearMessage:

TYPE: String

Optional: true

Default: "Please do not swear in this server!"

Info: If a swear word is caught, then this message will be sent

Example: "No swearing!"

• deleteSwearMessages:

TYPE: Boolean

Optional: true

Default: true

Info: If a swear word is caught, the message will be deleted

Example: "No swearing!"