Hybrid Commands

Create both prefix and slash commands from one code path.

Example Usage

Create it inside commands/hybrid/ping.ts.

1import { HybridCommand } from 'discordjs-nextgen';
2
3const pingHybrid: HybridCommand = {
4 name: 'ping',
5 description: 'Measure latency',
6 aliases: ['p'],
7 usage: 'ping',
8 category: 'general',
9 run: async (ctx) => {
10 const delay = Date.now() - ctx.createdAt.getTime();
11 await ctx.reply(`Pong! Latency: **${delay}ms**`);
12 },
13};
14
15export default pingHybrid;

Features

  • One run function for both messages and interactions.
  • Normalized ctx object.
  • Less duplicated code to maintain.
  • Alias support for prefix flows.