New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@migan/discord.js-commandhandler

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@migan/discord.js-commandhandler

easy discord.js commandHandler

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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

Keywords

discord.js

FAQs

Package last updated on 08 Sep 2021

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