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

discommand

Package Overview
Dependencies
Maintainers
0
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discommand

easy discord.js command handler.

latest
Source
npmnpm
Version
13.2.8
Version published
Weekly downloads
3
-94.44%
Maintainers
0
Weekly downloads
 
Created
Source

discommand

easy discord.js commandHandler

Installation

  • this is use for discord.js@14
  • Required by node.js 16.9.0 or higher
  • Stable version
npm i discommand
  • Development version
npm i discommand@next

Example

  • ** This examples is use es module.**

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!')
  }
}

Keywords

discord.js

FAQs

Package last updated on 23 Jul 2024

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