Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cmder.js

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cmder.js

Command & event handler for Discord.js

  • 1.0.2
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source
cmder.js logo

cmder.js

A node.js module to handle Discord.js commands and events.

Installation

Run one of the following commands based on your package manager:

npm install cmder.js
pnpm add cmder.js
yarn add cmder.js

Quickstart

Install the package, then create a new file in your root directory called 'cmder.yaml'. This will be our configuration file. It will look something like this:

paths:
  events: ./src/events
  commands: ./src/commands

Now, our src/index.js file:

const { Client } = require("discord.js");
const { Handler } = require("cmder.js");

const client = new Client({
  /* client config */
});

new Handler(client); // initialize the Handler class
client.login(TOKEN); // replace TOKEN with your bot's token

File setup

project
├── cmder.yaml
├── package.json
└── src/
    ├── index.js
    ├── commands/
    │   ├── General/
    │   │   ├── ping.js
    │   └── Misc/
    │       ├── info.js
    ├── events/
    │   ├── Client/
    │   │   ├── ready.js
    │   └── Messages/
    │       ├── messageCreate.js

Events

  • The name of the folder (e.g. "Client") does not matter.
  • The name of the file (e.g. "ready.js" or "console-log.js") does not matter.

What matters is what the event exports, which should look like this:

src/events/Client/ready.js

module.exports = {
  name: "ready" // This will be the name of our event (from client.on).
  once: true, // Optional. This will determine whether the event runs only once.

  run: (c) => { // The parameters are the same of doing client.on.
    console.log(`${c.user.tag} is now online!`);
  }
};

Commands

Commands are similar to events—neither the folder name nor the file name matter, but the exports do:

src/commands/General/ping.js

module.exports = {
  data: {
    // The command's information.
    // You can use builders if you'd like.

    name: "ping",
    description: "Replies with Pong!",
  },

  run: ({ interaction, client, handler }) => {
    interaction.reply("Pong!!!");
  },
};

Keywords

FAQs

Package last updated on 09 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc