Rehber DiSky #5 - Modal (Form) Oluşturma ve Etkileşime Girme

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

Furkan Doğan

¯⁠\⁠_⁠ʘ⁠‿⁠ʘ⁠_⁠/⁠¯
Emektar
MinePass
Katılım
14 Nisan 2023
Mesajlar
922
Elmaslar
239
Puan
5.605
Minecraft
FurkanDogan

Discord:

furkandogan.

Herkese Merhaba!

Uzun bir aradan sonra DiSky eklentisini tanıttığım rehber serisine bir konu daha açıyorum.

Bugünkü rehberimizde DiSky ile form oluşturup etkileşime gireceğiz.


Öncelikle belirteyim ki formları klasik komutlar ile değil butonlar, eğik çizgi komutları ya da menüler vasıtasıyla açabiliyoruz. Şimdi örnek olması için basit bir başvuru formu kodu hazırlayalım.


Ben buton ile yapmak istedim, siz yukarıda belirttiğim diğer iki seçeneği de kullanabilirsiniz.
Kod:
discord command $form-buton:
    trigger:
        purge event-message
        set {_buton} to new components row
        add new secondary button with url "basvuru-butonu" named "Başvuru Formu" with reaction "tools" to components of {_buton} 
        make embed:
            set title of embed to "Başvuru Formu"
            set description of embed to "Başvuru yapmak için butona tıklayın."
            set embed color of embed to orange
        reply with last embed with components {_buton}
1.png


Şimdi ise butona tıklayıp formu oluşturalım;
Kod:
on button click:
    if event-string is "basvuru-butonu":
        set {_form} to new modal with id "basvuru-formu" named "Başvuru Formu"

        set {_row::ad-soyad} to new components row
        set {_row::yaş} to new components row
        set {_row::telefon} to new components row
        set {_row::mail} to new components row
        set {_row::hakkınızda} to new components row

        set {_icerik::ad-soyad} to new short text input with id "basvuru-ad-soyad" named "Adınız & Soyadınız"
        set {_icerik::yaş} to new short text input with id "basvuru-yas" named "Yaşınız"
        set {_icerik::telefon} to new short text input with id "basvuru-telefon" named "Telefon Numaranız"
        set {_icerik::mail} to new short text input with id "basvuru-mail" named "Mail Adresiniz"
        set {_icerik::hakkınızda} to new text input with id "basvuru-hakkinizda" named "Hakkınızda"

        set required state of {_icerik::ad-soyad} to true
        set required state of {_icerik::yaş} to true
        set required state of {_icerik::telefon} to true
        set required state of {_icerik::mail} to true
        set required state of {_icerik::hakkınızda} to true

        set maximum range of {_icerik::ad-soyad} to 30
        set maximum range of {_icerik::yaş} to 30
        set maximum range of {_icerik::telefon} to 30
        set maximum range of {_icerik::mail} to 50
        set maximum range of {_icerik::hakkınızda} to 500

        add {_icerik::ad-soyad} to components of {_row::ad-soyad}
        add {_icerik::yaş} to components of {_row::yaş}
        add {_icerik::telefon} to components of {_row::telefon}
        add {_icerik::mail} to components of {_row::mail}
        add {_icerik::hakkınızda} to components of {_row::hakkınızda}

        set components row of {_form} to {_row::ad-soyad}, {_row::yaş}, {_row::telefon}, {_row::mail} and {_row::hakkınızda}
        show {_form} to user
2.png


Son olarak formu doldurup formların görüntüleneceği bir kanala gönderelim;
Kod:
on modal receive:
    if event-string is "basvuru-formu":
        make embed:
            set title of embed to "Yeni Bir Başvuru Formu Gönderildi!"
            set embed color of embed to orange
            add field named "Başvuruyu Yapan" with value mention tag of event-member to embed
            add field named "Adı & Soyadı" with value "`%value of textinput with id "basvuru-ad-soyad"%`" to embed
            add field named "Yaşı" with value "`%value of textinput with id "basvuru-yas"%`" to embed
            add field named "Telefon Numarası" with value "`%value of textinput with id "basvuru-telefon"%`" to embed
            add field named "Mail Adresi" with value "`%value of textinput with id "basvuru-mail"%`" to embed
            add field named "Hakkında" with value "`%value of textinput with id "basvuru-hakkinizda"%`" to embed
        post last embed to channel with id "KANAL ID with components {_buton}
        make embed:
            set title of embed to "Başvuru Formu"
            set description of the embed to "Başvuru formunuz gönderildi."
            set embed color of embed to orange
        reply with hidden last embed
3.png

5.png

4.png


Kodların tamamı;
Kod:
discord command $form-buton:
    trigger:
        purge event-message
        set {_buton} to new components row
        add new secondary button with url "basvuru-butonu" named "Başvuru Formu" with reaction "tools" to components of {_buton} 
        make embed:
            set title of embed to "Başvuru Formu"
            set description of embed to "Başvuru yapmak için butona tıklayın."
            set embed color of embed to orange
        reply with last embed with components {_buton}

on button click:
    if event-string is "basvuru-butonu":
        set {_form} to new modal with id "basvuru-formu" named "Başvuru Formu"

        set {_row::ad-soyad} to new components row
        set {_row::yaş} to new components row
        set {_row::telefon} to new components row
        set {_row::mail} to new components row
        set {_row::hakkınızda} to new components row

        set {_icerik::ad-soyad} to new short text input with id "basvuru-ad-soyad" named "Adınız & Soyadınız"
        set {_icerik::yaş} to new short text input with id "basvuru-yas" named "Yaşınız"
        set {_icerik::telefon} to new short text input with id "basvuru-telefon" named "Telefon Numaranız"
        set {_icerik::mail} to new short text input with id "basvuru-mail" named "Mail Adresiniz"
        set {_icerik::hakkınızda} to new text input with id "basvuru-hakkinizda" named "Hakkınızda"

        set required state of {_icerik::ad-soyad} to true
        set required state of {_icerik::yaş} to true
        set required state of {_icerik::telefon} to true
        set required state of {_icerik::mail} to true
        set required state of {_icerik::hakkınızda} to true

        set maximum range of {_icerik::ad-soyad} to 30
        set maximum range of {_icerik::yaş} to 30
        set maximum range of {_icerik::telefon} to 30
        set maximum range of {_icerik::mail} to 50
        set maximum range of {_icerik::hakkınızda} to 500

        add {_icerik::ad-soyad} to components of {_row::ad-soyad}
        add {_icerik::yaş} to components of {_row::yaş}
        add {_icerik::telefon} to components of {_row::telefon}
        add {_icerik::mail} to components of {_row::mail}
        add {_icerik::hakkınızda} to components of {_row::hakkınızda}

        set components row of {_form} to {_row::ad-soyad}, {_row::yaş}, {_row::telefon}, {_row::mail} and {_row::hakkınızda}
        show {_form} to user

on modal receive:
    if event-string is "basvuru-formu":
        make embed:
            set title of embed to "Yeni Bir Başvuru Formu Gönderildi!"
            set embed color of embed to orange
            add field named "Başvuruyu Yapan" with value mention tag of event-member to embed
            add field named "Adı & Soyadı" with value "`%value of textinput with id "basvuru-ad-soyad"%`" to embed
            add field named "Yaşı" with value "`%value of textinput with id "basvuru-yas"%`" to embed
            add field named "Telefon Numarası" with value "`%value of textinput with id "basvuru-telefon"%`" to embed
            add field named "Mail Adresi" with value "`%value of textinput with id "basvuru-mail"%`" to embed
            add field named "Hakkında" with value "`%value of textinput with id "basvuru-hakkinizda"%`" to embed
        post last embed to channel with id "KANAL ID" with components {_buton}
        make embed:
            set title of embed to "Başvuru Formu"
            set description of the embed to "Başvuru formunuz gönderildi."
            set embed color of embed to orange
        reply with hidden last embed



Bugünlük bu kadar, vakit ayırdığınız için teşekkürler.
 
Aradığımı istemeden bulmuş oldum, seriyi takip ediyorum.
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

Hala Discord sunucumuza katılmadın mı?

Büyük bir topluluğun parçası ol, etkinliklere katıl ve özel hediyeler kazanma şansı yakala!

Şimdi Katıl
Üst