A Discord.JS Command Handler to handle commands eaiser

Overview

TABLE OF CONTENTS

Installation

NPM

npm i commanding.js

You can install the latest work in progress by -

npm i "https://github.com/CodyAaTherf/commanding.js#dev"

Note that these features are still in work in progress and some might not have been completed yet and your bot might break. You can check on to here to know more!

Setup

How to setup commanding.js -

const { Client , Intents } = require('discord.js')
const CommandingJS = require('commanding.js')
const { token } = require('./config.json')

const client = new Client({ intents: [Intents.FLAGS.GUILDS , Intents.FLAGS.GUILD_MESSAGES] });

client.once('ready' , () => {
    console.log("Ready!");

    new CommandingJS(client , 'commands')
})

client.login(token)

Prefixes

The default prefix of the bot on installing this package will be - > . You can change it in your main file using -

new CommandingJS(client)
    .setDefaultPrefix('!')

Creating a Command

Here's how to create a ping command -

module.exports = {
    name: 'ping' , // required
    commands: ['p'] ,
    description: 'Ping' , // optional
    callback: (message) => {
      message.reply('Pong!')
    }
}

You can either use commands: [''] or aliases: [''] , either works but you have to use one atleast.

Users can use >ping or >p and use the command.

minArgs & maxArgs

Minimum and Maximum number of args a user has to use before they can use the command. In this example the bot will ping the user you ping.

// ping-member.js

module.exports = {
    name: 'ping-member' ,
    commands: ['ping-member' , 'pingmember' , 'pm'] ,
    description: 'Bot pings the member you ping' ,
    minArgs: 1 ,
    maxArgs: 1 ,
    callback: (message) => {
        const { mentions } = message
        const target = mentions.users.first()

        if(target){
            message.channel.send(`Hello , ${target} !`)
        }
    }
}

Note - minArgs cannot be less than maxArgs or you will get an error.

Syntax Error

Global Syntax Error -

The default syntaxError is Wrong Syntax ! You can change it in your main file using -

new CommandingJS(client)
    .setSyntaxError("")

Per-Command Syntax Error -

You can specify the syntax error for each command using -

module.exports = {
    name: 'ping-member' ,
    commands: ['ping-member' , 'pingmember' , 'pm'] ,
    description: 'Bot pings the member you ping' ,
    syntaxError: 'wrong symtax! use {PREFIX}{COMMAND} <@mention>' ,
    minArgs: 1 ,
    maxArgs: 1 ,
    callback: (message) => {
        const { mentions } = message
        const target = mentions.users.first()

        if(target){
            message.channel.send(`Hello , ${target} !`)
        }
    }
}

You can use - {PREFIX} - to show the bot's perfix on the Error

{COMMAND} - command name

Permissions

Making a ban command or any other command that requires permissions? You can do it by -

module.exports = {
    name: 'ping' ,
    commands: ['p'] , // or aliases: ['p'] . either works
    description: 'Ping' ,
    requiredPermissions: ['ADMINISTRATOR'] ,
    callback: (message) => {
      message.reply('Pong!')
    }
}

Here are all the permissions that you might have to use.

MongoDB Connection

MongoDB Connection is optional. You will need it to use the built in commands or any commands that you use that requires to save data. You can define it in the main file using -

// index file

const config = require('./config.json')

new CommandingJS(client)
    .setMongoPath(config.mongo_uri)

config.json

{
    "token": "" ,
    "mongo_uri": ""
}

Built in commands -

>prefix - Displays the prefix of the bot

>prefix <new prefix> - Changes the prefix of the bot. It is supported per server. Required MongoDB Connection. See MongoDB Connection to know to to connect to MongoDB.

>command <enable | disable> <command name> - Enable or Disable any command. It is supported per server. Requires MongoDB Connection.

>commands - Displays all the current commands of the bot.

SOURCES

All these snippets have come from Commanding.JS Test Repository. It has been maintained by me itself.

You might also like...

A utility package for making discord-bot commands much easier to write with discord.js.

Cordcommand About A utility package for making discord-bot commands much easier to write with discord.js. Usage Example // initiate discord.js client

Dec 13, 2022

An Amazing SlashCommands Handler (With Sharding & Mongo) Made by discord.gg/azury

An Amazing SlashCommands Handler (With Sharding & Mongo) Made by discord.gg/azury

SlashCommands Handler by The Azury Team If this Git-Repo gets "40" Stars ⭐ i'll add some more Commands! 🛠️ FEATURES: 1. SlashCommands Support 2. Cont

Dec 2, 2022

Run a command, watch the filesystem, stop the process on file change and then run the command again...

hubmon Run a command, watch the filesystem, stop the process on file change and then run the command again... Install You can install this command lin

Jul 30, 2022

Some process handle JavaScript function parameter.

Function parameter handle or paremeter error control Example 1: Just checking if all arguments were passed / defined. const required = (name) = {

Mar 14, 2022

A set of useful helper methods for writing functions to handle Cloudflare Pub/Sub messages (https://developers.cloudflare.com/pub-sub/)

pubsub A set of useful helper methods for writing functions to handle Cloudflare Pub/Sub messages. This includes: A isValidBrokerRequest helper for au

Dec 4, 2022

Handle errors like it's 2022 🔮

Handle errors like it's 2022 🔮 Error handling framework that is minimalist yet featureful. Features Minimalist API Custom error types Wrap any error'

Jan 7, 2023

Helper package to handle requests to a jschan api instance.

jschan-api-sdk Helper package to handle requests to a jschan api instance. How to use npm install ussaohelcim/jschan-api-sdk const { jschan } = requir

Jun 30, 2022

Small TS library to type and safely handle `serde` JSON serializations of Rust enums.

rustie-ts TypeScript library with helper types and functions to type-safely handle Rust's serde JSON serialization of Enums. It can also be used stand

Jul 17, 2022

This is just a script I put together to check and notify me via email (MailGun) when there's an earlier date before my initial appointment date. It doesn't handle rescheduling.

This is just a script I put together to check and notify me via email (MailGun) when there's an earlier date before my initial appointment date. It doesn't handle rescheduling.

US-visa-appointment-notifier This is just a script I put together to check and notify me via email (MailGun) when there's an earlier date before my in

Jan 4, 2023
Comments
  • 1.2.0

    1.2.0

    Changes -

    Built in commands Syntax Errors Permissions MongoDB Connection

    Look at Readme to know about how to use them!

    https://github.com/CodyAaTherf/commandingjs-tests https://www.npmjs.com/package/commanding.js

    opened by CodyAaTherf 0
  • Version 1.1.0

    Version 1.1.0

    TABLE OF CONTENTS

    Installation

    NPM

    npm i commanding.js
    

    Setup

    How to setup commanding.js -

    const { Client , Intents } = require('discord.js')
    const CommandingJS = require('commanding.js')
    const { token } = require('./config.json')
    
    const client = new Client({ intents: [Intents.FLAGS.GUILDS , Intents.FLAGS.GUILD_MESSAGES] });
    
    client.once('ready' , () => {
        console.log("Ready!");
    
        new CommandingJS(client , 'commands')
    })
    
    client.login(token)
    

    Creating a Command

    Here's how to create a ping command -

    module.exports = {
        name: 'ping' , // required
        commands: ['p'] ,
        description: 'Ping' , // optional
        callback: (message) => {
          message.reply('Pong!')
        }
    }
    

    You can either use commands: [''] or aliases: [''] , either works but you have to use one atleast.

    Users can use >ping or >p and use the command.

    opened by CodyAaTherf 0
Releases(1.2.0)
  • 1.2.0(Jun 5, 2022)

    Changes -

    Built in commands Syntax Errors Permissions MongoDB Connection

    Look at Readme to know about how to use them!

    https://github.com/CodyAaTherf/commandingjs-tests https://www.npmjs.com/package/commanding.js

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Jun 4, 2022)

    What's new?

    Support for minArgs and maxArgs Change default prefix of the bot

    Look at Readme to know about how to use them!

    https://github.com/CodyAaTherf/commandingjs-tests https://www.npmjs.com/package/commanding.js

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(May 30, 2022)

    TABLE OF CONTENTS

    Installation

    NPM

    npm i commanding.js
    

    Setup

    How to setup commanding.js -

    const { Client , Intents } = require('discord.js')
    const CommandingJS = require('commanding.js')
    const { token } = require('./config.json')
    
    const client = new Client({ intents: [Intents.FLAGS.GUILDS , Intents.FLAGS.GUILD_MESSAGES] });
    
    client.once('ready' , () => {
        console.log("Ready!");
    
        new CommandingJS(client , 'commands')
    })
    
    client.login(token)
    

    Creating a Command

    Here's how to create a ping command -

    module.exports = {
        name: 'ping' , // required
        commands: ['p'] ,
        description: 'Ping' , // optional
        callback: (message) => {
          message.reply('Pong!')
        }
    }
    

    You can either use commands: [''] or aliases: [''] , either works but you have to use one atleast.

    Users can use >ping or >p and use the command.

    Source code(tar.gz)
    Source code(zip)
Owner
AaTherf
I mainly code in JavaScript & Python.
AaTherf
A Discord bot Template made with Discord.JS version 14 includes Prefix, Slash commands and MongoDB handler.

Project Language: Fork/Download for: Project Requirements: Database Available: DiscordJS V14 Bot Template - Introduction: A Discord bot project made w

T.F.A 105 Jan 3, 2023
New Discord.JS v14 Slash and Prefix Commands handler with Events. Check it out now!

Discord.js v14 Command-Handler Commands, Events, Permissions and Cooldown Handlers for Discord.js v14 bot ~ Made by Lynx Discord.js v14 (dev version)

Comet Development 20 Dec 19, 2022
🤖 Makes it easy to create bots on discord through a simple command handler

MyBotHelper.JS ?? About facilitates the creation of bots via discord.js, the repository already has a main script that automatically synchronizes and

Marcus Rodrigues 4 Dec 31, 2022
DKRCommands is a Discord.js command handler.

DKRCommands is a Discord.js command handler for Discord.js v14 built as a rework of WOKCommands by Worn Off Keys. The goal of this package is to make

Karel Krýda 5 Dec 3, 2022
A good looking help command made with discord.js with select menus. Works with prefix and slash commands too!

fancy-help-command A good looking help command made with discord.js with select menus. Works with prefix and slash commands too! Dependencies: Select

LunarCodes 11 Dec 12, 2022
V14 Slash Command Handler! (ES6 Module Destekli)

V14 Slash Command Handler Proje discord.js v14 üzerine yazılmıştır. Gerekli olan minimum nodejs versiyonu v16.9 Örnek kullanım src/commands/ping.js do

Mehmet 137 Dec 31, 2022
All terminal commands in one place (you can Contribute to it by putting latest commands and adding Readme)

Terminal-Commands All basic terminal commands in one place Show some ❤ by some repositories You can contribute to this readme If you to contribute wit

Shehzad Iqbal 7 Dec 15, 2022
Cypress commands are asynchronous. It's a common pattern to use a then callback to get the value of a cypress command

cypress-thenify Rationale Cypress commands are asynchronous. It's a common pattern to use a then callback to get the value of a cypress command. Howev

Mikhail Bolotov 15 Oct 2, 2022
A command line application to simplify the git workflow on committing, pushing and others commands.

Git-Suite A command line application to simplify the git workflow on committing, pushing and others commands. Prerequisites Install Node Package Manag

Lucas Gobatto 5 Aug 10, 2022
A discord bot to track "owo", usually used to help with OwO bot. Made with Discord.js v13 includes Slash commands, Leaderboards, Auto Resets etc.

Discord-OwO-tracker A discord bot to track "owo", usually used to help with OwO bot Requirements Discord.js v13 (npm install discord.js@latest) applic

Astrex 4 Nov 24, 2022