This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@migan/discord.js-commandhandler
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

discord.js-commandhandler

easy discord.js commandHandler

Installation

this is use discord.js@13

npm i @migan/discord.js-commandhandler

dev

npm i @migan/discord.js-commandhandler@next

Example

ts

MessageCommand

index.ts

import { commandHandlerClient } from "@migan/discord.js-commandhandler";
import { Intents } from "discord.js";

const client = new commandHandlerClient({
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
  prefix: "!",
  path: __dirname + "/commands",
  token: "your_bot_token",
});

client.loadCommandWithFile(); // else client.loadCommandWithFolder();

client.on("messageCreate", (msg) => {
  client.runMessage(msg, client);
});

client.login();

commands/ping.ts

import type { Message } from "discord.js";
import {
  MessageCommand,
  commandHandlerClient,
} from "@migan/discord.js-commandhandler";

export class command extends MessageCommand {
  name = "ping";
  execute(msg: Message, client: commandHandlerClient, args: any) {
    msg.reply("pong!");
  }
}

slashCommand

index.ts

import { commandHandlerClient } from "@migan/discord.js-commandhandler";
import { Intents } from "discord.js";

const client = new commandHandlerClient({
  intents: [Intents.FLAGS.GUILDS],
  path: __dirname + "/commands",
  token: "your_bot_token",
});

client.loadSlashGuildCmdWithFile(clientId, guildId);

client.on("interactionCreate", (interaction) => {
  client.runSlash(interaction, client);
});

client.login();

commands/ping.ts

import { CommandInteraction } from "discord.js";
import { SlashCommandBuilder } from "@discordjs/builders";
import {
  slashCommand,
  commandHandlerClient,
} from "@migan/discord.js-commandhandler";

export class command extends slashCommand {
  data = new SlashCommandBuilder().setName("ping").setDescription("pong");
  async execute(interaction: CommandInteraction, client: commandHandlerClient) {
    await interaction.reply("pong!");
  }
}

js

MessageCommand

index.js

const { commandHandlerClient } = require("@migan/discord.js-commandhandler");
const { Intents } = require("discord.js");

const client = new commandHandlerClient({
  intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
  prefix: "!",
  path: __dirname + "/commands",
  token: "your_bot_token",
});

client.loadCommandWithFile(); // else client.loadCommandWithFolder();

client.on("messageCreate", (msg) => {
  client.runMessage(msg, client);
});

client.login();

commands/ping.js

const { MessageCommand } = require("@migan/discord.js-commandhandler");

exports.command = class command extends MessageCommand {
  name = "ping";
  execute(msg, client, args) {
    msg.reply("pong!");
  }
};

slashCommand

index.js

const { commandHandlerClient } = require("@migan/discord.js-commandhandler");
const { Intents } = require("discord.js");

const client = new commandHandlerClient({
  intents: [Intents.FLAGS.GUILDS],
  path: __dirname + "/commands",
  token: "your_bot_token",
});

client.loadSlashGuildCmdWithFile(clientId, guildId);

client.on("interactionCreate", (interaction) => {
  client.runSlash(interaction, client);
});

client.login();

commands/ping.js

const { SlashCommandBuilder } = require("@discordjs/builders");
const { slashCommand } = require("@migan/discord.js-commandhandler");

exports.command = class command extends slashCommand {
  data = new SlashCommandBuilder().setName("ping").setDescription("pong");
  execute(interaction, client) {
    interaction.reply("pong!");
  }
};

Readme

Keywords

Package Sidebar

Install

npm i @migan/discord.js-commandhandler

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

24.8 kB

Total Files

16

Last publish

Collaborators

  • migan