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

Overview

Cordcommand

About

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

Usage Example

// initiate discord.js client
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers,
  ],
});

// define your commands similar to
const commands: Commands = {
  interactionCreate: [
    // define interactions here
    {
      name: "ping",
      cb: async (interaction) => {
        await interaction.reply("Pong!");
      },
    },
  ],

  messageCreate: [
    {
      regex: /ping/i,
      message: "pong",
    },
    {
      regex: /hi/i,
      // message can also be a callback function which can access the discord message object
      message: (_, message) => `hello <@${message.author.id}>`,
    },
    {
      regex: /bye/i,
      message: (_, message) => `bye ${message.author.username}`,
      reply: true, // uses discord's message.reply intead of just sending the message in the same channel
    },
    {
      regex: /args/i,
      message: (args) => `The arguments are: ${args.join(", ")}`,
      reply: true, 
    },
  ],
};

// add commands to the client by calling the addCommands function provided by the client
addCommands(client, commands, {
  messageCommandPrefix: /^i!/i,
  // Add your command prefix regex. Make sure to include ^ (starts with) in the regex
});

// login
client.login(process.env.BOT_TOKEN!);
You might also like...

Execute obsidian commands with short key sequences. For example, 'tp' for 'Toggle Preview' and 'tb' for 'Toggle Sidebar'. Easier to remember.

Execute obsidian commands with short key sequences. For example, 'tp' for 'Toggle Preview' and 'tb' for 'Toggle Sidebar'. Easier to remember.

Key Sequence Shortcut Key Sequence Shortcut is an obsidian plugin, allow binding key sequences to an obsidian command. For example If we assume "t" st

Dec 26, 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

Dec 15, 2022

Discord.js bot starter template, Slash Commands only (Raymond forced me to make a bot template)

boat-template Raymond forced me to make a bot template This template is meant is just for stupidness ig Getting Started Rename the config.example.ts t

Jan 5, 2022

Reference for How to Write an Open Source JavaScript Library - https://egghead.io/series/how-to-write-an-open-source-javascript-library

Reference for How to Write an Open Source JavaScript Library The purpose of this document is to serve as a reference for: How to Write an Open Source

Dec 24, 2022

Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test and also deploy.

GraphQL Blog graphqlblog.com Learn GraphQL by building a blogging engine. Create resolvers, write schemas, write queries, design the database, test an

Aug 17, 2022

Boiler is a utility library that makes every day tasks in JavaScript easier by providing over 115 methods

Boiler is a utility library that makes every day tasks in JavaScript easier by providing over 115 methods that work on arrays, collections, functions, numbers, objects, and strings. It's the JavaScript equivalent of a Swiss Army Knife.

Nov 1, 2022

A Discord bot Template made with Discord.JS version 14 includes Prefix, Slash commands and MongoDB handler.

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

Jan 3, 2023
Owner
NLP practitioners
A group of NLP enthusiast engaging in research and code collaboration
NLP practitioners
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An extension that makes Scratching much easier!

ScratchTools An extension that makes Scratching much easier! Official Discord. v1.0 ScratchTools Version 1.0 had multiple bugs, making it impossible t

rgantzos 0 May 23, 2022
The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.

EaselJS EaselJS is a library for building high-performance interactive 2D content in HTML5. It provides a feature-rich display list to allow you to ma

CreateJS 8k Dec 29, 2022
Package fetcher is a bot messenger which gather npm packages by uploading either a json file (package.json) or a picture representing package.json. To continue...

package-fetcher Ce projet contient un boilerplate pour un bot messenger et l'executable Windows ngrok qui va permettre de créer un tunnel https pour c

AILI Fida Aliotti Christino 2 Mar 29, 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
A framework dedicated to making it easier for you to build enterprise-grade PWA applications.

A framework dedicated to making it easier for you to build enterprise-grade PWA applications.

JerryC 181 Oct 6, 2022
Solid Forms provides several form control objects useful for making working with forms easier.

Solid Forms Solid Forms provides several form control objects useful for making working with forms easier. Demos and examples below. # solidjs yarn ad

John 28 Jan 2, 2023
An easy-to-use JavaScript library aimed at making it easier to draw on SVG elements.

svg-pen-sketch An easy-to-use JavaScript library aimed at making it easier to draw on SVG elements when using a digital pen (such as the Surface Pen).

Kevin Desousa 8 Jul 27, 2022
A template created with the intention of making my life easier when starting a project, and the lives of other people. :>

Express API A simple and improved api with ExpressJS. ?? | Glossary Dependencies How to Start Routes Controllers & Models License Author ?? | Dependec

Feh's 3 Sep 22, 2022