Buton Kullanımı

Etkileşimli butonlar oluşturun ve tıklamaları kolayca işleyin.

Buton İşleyici (ButtonHandler)

buttons/verify.ts dosya dizininde oluşturun.

1import { ButtonHandler } from 'discordjs-nextgen';
2
3const verifyButton: ButtonHandler = {
4 customId: 'verify_user', // Butonun custom_id'si ile eşleşir
5 run: async (ctx) => {
6 // ctx.user butonun basan kullanıcıdır
7 await ctx.reply({ content: 'Doğrulandınız!', ephemeral: true });
8 },
9};
10
11export default verifyButton;

Modern Buton Oluşturma

Mesaj göndermek için butonları ActionRow ile gruplayın.

1import { Button, ActionRow } from 'discordjs-nextgen';
2
3const row = ActionRow.create(
4 Button.create('test_btn')
5 .setLabel('Tıkla')
6 .setStyle('Primary'),
7
8 Button.create()
9 .setLabel('Google')
10 .setURL('https://google.com')
11);
12
13await ctx.reply({ content: 'Bir buton seçin:', components: [row] });

Özellikler

  • Sınıfsal Yapı: Button sınıfı ile hızlı tasarımlar yapın.
  • CustomId Matching: Belirlediğiniz ID ile handler otomatik eşleşir.
  • ActionRow Entegrasyonu: Butonları tek bir satıra ekleyerek düzeni sağlayın.
  • Tip Desteği: Buton stillerini TypeScript ile kolayca seçin.