discommand
TypeScript icon, indicating that this package has built-in type declarations

13.2.6 • Public • Published

discommand

easy discord.js commandHandler

Installation

  • alert! this is Pure ES Module.
  • this is use for discord.js@14
  • Required by node.js 16.9.0 or higher
  1. Stable version
npm i discommand
  1. Development version
npm i discommand@next

Example

Usage for TypeScript

index.ts

import { DiscommandClient } from 'discommand'
import { GatewayIntentBits } from 'discord.js'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

const client = new DiscommandClient(
  {
    intents: [GatewayIntentBits.Guilds],
  },
  {
    directory: {
      command: dirname(fileURLToPath(import.meta.url)) + '/commands',
    },
  }
)

client.login('your_bot_token')

commands/ping.ts

import { Command } from 'discommand'
import { ChatInputCommandInteraction, ApplicationCommandType } from 'discord.js'

export default class extends Command {
  constructor() {
    super({
      name: 'ping',
      description: 'Pong',
      type: ApplicationCommandType.ChatInput,
    })
  }

  execute(interaction: ChatInputCommandInteraction) {
    interaction.reply('Pong!')
  }
}

Usage for Javascript

index.js

import { DiscommandClient } from 'discommand'
import { GatewayIntentBits } from 'discord.js'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

const client = new DiscommandClient(
  {
    intents: [GatewayIntentBits.Guilds],
  },
  {
    directory: {
      command: dirname(fileURLToPath(import.meta.url)) + '/commands',
    },
  }
)

client.login('your_bot_token')

commands/ping.js

import { Command } from 'discommand'
import { ApplicationCommandType } from 'discord.js'

export default class extends Command {
  constructor() {
    super({
      name: 'ping',
      description: 'Pong',
      type: ApplicationCommandType.ChatInput,
    })
  }
  execute(interaction) {
    interaction.reply('Pong!')
  }
}

Package Sidebar

Install

npm i discommand

Weekly Downloads

7

Version

13.2.6

License

MIT

Unpacked Size

14.8 kB

Total Files

5

Last publish

Collaborators

  • migan