discommand-lite
discommand, but Command Handler only
Installation
- this is use for discord.js@14
- Required by node.js 16.9.0 or higher
- Stable version
npm i discommand-lite
- Devlopment version
npm i discommand-lite@next
Example
Usage for TypeScript
index.ts
import { CommandHandler, LoadType } from '@discommand/lite'
import { Client, GatewayIntentBits } from 'discord.js'
import * as path from 'path'
const client = new Client({
intents: [GatewayIntentBits.Guilds],
})
const cmd = new CommandHandler(client, {
loadType: LoadType.File,
directory: path.join(__dirname, 'commands'),
})
cmd.loadAll()
client.login('your_bot_token')
commands/ping.ts
import { Command } from '@discommand/lite'
import { ChatInputCommandInteraction } from 'discord.js'
export default class extends Command {
name = 'ping'
description = 'pong'
execute(interaction: ChatInputCommandInteraction) {
interaction.reply('Pong!')
}
}
Usage for Javascript
index.js
const { CommandHandler, LoadType } = require('@discommand/lite')
const { Client, GatewayIntentBits } = require('discord.js')
const path = require('path')
const client = new Client({
intents: [GatewayIntentBits.Guilds],
})
const cmd = new CommandHandler(client, {
loadType: LoadType.File,
directory: path.join(__dirname, 'commands'),
})
cmd.loadAll()
client.login('your_bot_token')
commands/ping.js
const { Command } = require('@discommand/lite')
module.exports = class extends Command {
name = 'ping'
description = 'pong'
execute(interaction) {
interaction.reply('Pong!')
}
}