Slash Komutu Oluşturma

DiscordSlash komutlarını oluşturun ve uygulama ile entegre edin. Discord'un yerel Slash komut sistemini kullanır.

Örnek Kullanım ve Modal Açma

commands/slash/register.ts dosya dizininde oluşturun.

1import { Modal, SlashCommandBuilder } from 'discordjs-nextgen';
2
3const registerCommand = {
4 data: new SlashCommandBuilder()
5 .setName('kayıt')
6 .setDescription('Kayıt formunu açar'),
7 category: 'user', // Komut kategorisi
8 usage: 'kayıt', // Kullanım şekli
9 aliases: ['register'], // Discord'da ayrı bir slash komutu olarak kaydedilir
10 run: async (ctx) => {
11 // Manuel modal oluşturup gösterme
12 const modal = Modal.create('reg_modal')
13 .title('Kayıt Sistemi')
14 .short('username', { label: 'Kullanıcı Adı' })
15 .paragraph('bio', { label: 'Hakkında', required: false });
16
17 await ctx.showModal(modal);
18 }
19};
20
21export default registerCommand;

Özellikler

  • SlashCommandBuilder: Standart Discord.js SlashCommandBuilder ile tam uyumludur.
  • Otomatik Kayıt: app.slash() ile tüm komutlar otomatik olarak Discord'a kaydedilir.
  • Slash-Specific Aliases: aliases listesindeki her isim ayrı bir slash komutu olarak kaydedilir.
  • Modal Desteği: Slash komutu üzerinden kolayca form (Modal) açılabilir.