@@ -22,6 +22,19 @@ def __init__(self, *args, **kwargs) -> None:
22
22
label = "Longer Input" ,
23
23
value = "Longer Value\n Super Long Value" ,
24
24
style = discord .InputTextStyle .long ,
25
+ description = "You can also describe the purpose of this input."
26
+ ),
27
+ discord .ui .TextDisplay ("# Personal Questions" ),
28
+ discord .ui .Select (
29
+ label = "What's your favorite color?" ,
30
+ placeholder = "Select a color" ,
31
+ options = [
32
+ discord .SelectOption (label = "Red" , emoji = "🟥" ),
33
+ discord .SelectOption (label = "Green" , emoji = "🟩" ),
34
+ discord .SelectOption (label = "Blue" , emoji = "🟦" ),
35
+ ],
36
+ description = "If it is not listed, skip this question." ,
37
+ required = False
25
38
),
26
39
* args ,
27
40
** kwargs ,
@@ -70,36 +83,36 @@ async def modal_user(ctx: discord.ApplicationContext, member: discord.Member):
70
83
async def modaltest (ctx : commands .Context ):
71
84
"""Shows an example of modals being invoked from an interaction component (e.g. a button or select menu)"""
72
85
73
- class MyView (discord .ui .View ):
74
- @discord .ui .button (label = "Modal Test" , style = discord .ButtonStyle .primary )
75
- async def button_callback (
76
- self , button : discord .ui .Button , interaction : discord .Interaction
77
- ):
78
- modal = MyModal (title = "Modal Triggered from Button" )
79
- await interaction .response .send_modal (modal )
80
-
81
- @discord .ui .select (
82
- placeholder = "Pick Your Modal" ,
83
- min_values = 1 ,
84
- max_values = 1 ,
85
- options = [
86
- discord .SelectOption (
87
- label = "First Modal" , description = "Shows the first modal"
88
- ),
89
- discord .SelectOption (
90
- label = "Second Modal" , description = "Shows the second modal"
91
- ),
92
- ],
93
- )
94
- async def select_callback (
95
- self , select : discord .ui .Select , interaction : discord .Interaction
96
- ):
97
- modal = MyModal (title = "Temporary Title" )
98
- modal .title = select .values [0 ]
99
- await interaction .response .send_modal (modal )
100
-
101
- view = MyView ()
102
- await ctx .send ("Click Button, Receive Modal" , view = view )
86
+ class MyView (discord .ui .View ):
87
+ @discord .ui .button (label = "Modal Test" , style = discord .ButtonStyle .primary )
88
+ async def button_callback (
89
+ self , button : discord .ui .Button , interaction : discord .Interaction
90
+ ):
91
+ modal = MyModal (title = "Modal Triggered from Button" )
92
+ await interaction .response .send_modal (modal )
93
+
94
+ @discord .ui .select (
95
+ placeholder = "Pick Your Modal" ,
96
+ min_values = 1 ,
97
+ max_values = 1 ,
98
+ options = [
99
+ discord .SelectOption (
100
+ label = "First Modal" , description = "Shows the first modal"
101
+ ),
102
+ discord .SelectOption (
103
+ label = "Second Modal" , description = "Shows the second modal"
104
+ ),
105
+ ],
106
+ )
107
+ async def select_callback (
108
+ self , select : discord .ui .Select , interaction : discord .Interaction
109
+ ):
110
+ modal = MyModal (title = "Temporary Title" )
111
+ modal .title = select .values [0 ]
112
+ await interaction .response .send_modal (modal )
113
+
114
+ view = MyView ()
115
+ await ctx .send ("Click Button, Receive Modal" , view = view )
103
116
104
117
105
118
bot .run ("TOKEN" )
0 commit comments