1.0.2 • Published 8 months ago

rocket-djs v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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}!`);
};