Giter Site home page Giter Site logo

rocket-djs's Introduction

rocket-djs

rocket-djs is a Discord.js bot handler designed to simplify handling both slash commands and events.

Installation

Using npm

npm install rocket-djs

Using Yarn

yarn add rocket-djs

Using pnpm

pnpm add rocket-djs

Examples

// CommonJS
const { Handler } = require("rocket-djs");
const { Client } = require("discord.js");

const path = require("path");

// ESM and TypeScript
import { Handler } from "rocket-djs";
import { Client } from "discord.js";

import path from "path";

const client = new Client(); // Client options such as intents.

new Handler(client, {
    // It is recommended to use the path library to avoid import issues.
    eventsPath: path.join(__dirname, "events"),
    commandsPath: path.join(__dirname, "commands"),
});

// Replace TOKEN with your bot's token.
client.login(TOKEN)

Example Command

// commands/Misc/ping.js

// export or export default for ESM
// module.exports for CommonJS

// Using SlashCommandBuilder or ContextMenuCommandBuilder
export const data = new SlashCommandBuilder()
    .setName("ping")
    .setDescription("Replies with Pong!");

// Or with JSON:
export const data = {
    name: "ping",
    description: "Replies with Pong!",
    // read more below:
    // https://discord.com/developers/docs/interactions/application-commands#app-mount
};

// The main run function.
export function run(interaction) {
    interaction.reply("Pong!!!");
};

Example Event

// export for ESM
// module.exports for CommonJS

// You can also use export default if you prefer.
export const name = "ready"; // The event name - client.on(name)
export function run(client) {
    // The main run function.
    // Arguments in run are the same as doing client.on(name, ...args)
    console.log(`Logged in as ${client.user.tag}!`);
};

rocket-djs's People

Contributors

notm1dev avatar

Stargazers

Avraj Sahota avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.