@@ -84,37 +84,37 @@ async def modaltest(ctx: commands.Context):
8484 """Shows an example of modals being invoked from an interaction component (e.g. a button or select menu)"""
8585
8686
87- class MyView (discord .ui .View ):
88- @discord .ui .button (label = "Modal Test" , style = discord .ButtonStyle .primary )
89- async def button_callback (
90- self , button : discord .ui .Button , interaction : discord .Interaction
91- ):
92- modal = MyModal (title = "Modal Triggered from Button" )
93- await interaction .response .send_modal (modal )
94-
95- @discord .ui .select (
96- placeholder = "Pick Your Modal" ,
97- min_values = 1 ,
98- max_values = 1 ,
99- options = [
100- discord .SelectOption (
101- label = "First Modal" , description = "Shows the first modal"
102- ),
103- discord .SelectOption (
104- label = "Second Modal" , description = "Shows the second modal"
105- ),
106- ],
107- )
108- async def select_callback (
109- self , select : discord .ui .Select , interaction : discord .Interaction
110- ):
111- modal = MyModal (title = "Temporary Title" )
112- modal .title = select .values [0 ]
113- await interaction .response .send_modal (modal )
114-
115-
116- view = MyView ()
117- await ctx .send ("Click Button, Receive Modal" , view = view )
87+ class MyView (discord .ui .View ):
88+ @discord .ui .button (label = "Modal Test" , style = discord .ButtonStyle .primary )
89+ async def button_callback (
90+ self , button : discord .ui .Button , interaction : discord .Interaction
91+ ):
92+ modal = MyModal (title = "Modal Triggered from Button" )
93+ await interaction .response .send_modal (modal )
94+
95+ @discord .ui .select (
96+ placeholder = "Pick Your Modal" ,
97+ min_values = 1 ,
98+ max_values = 1 ,
99+ options = [
100+ discord .SelectOption (
101+ label = "First Modal" , description = "Shows the first modal"
102+ ),
103+ discord .SelectOption (
104+ label = "Second Modal" , description = "Shows the second modal"
105+ ),
106+ ],
107+ )
108+ async def select_callback (
109+ self , select : discord .ui .Select , interaction : discord .Interaction
110+ ):
111+ modal = MyModal (title = "Temporary Title" )
112+ modal .title = select .values [0 ]
113+ await interaction .response .send_modal (modal )
114+
115+
116+ view = MyView ()
117+ await ctx .send ("Click Button, Receive Modal" , view = view )
118118
119119
120120bot .run ("TOKEN" )
0 commit comments