2828from discord .ext import commands
2929from typing import Any
3030
31- from .utils import DynamicViewManager , Pagination
31+ from .utils import DynamicViewManager , Pagination , BaseModal
3232from .pagination import PaginationView
3333from ..config import Config
3434from ..utils import format_ms , truncate_string , dispatch_message
@@ -144,7 +144,9 @@ def update_view(self, extra_states = None):
144144 async def on_error (self , interaction : discord .Interaction , error : Exception , item : discord .ui .Item ) -> None :
145145 if isinstance (error , VoicelinkException ):
146146 return await dispatch_message (interaction , content = getattr (error , 'original' , error ), ephemeral = True )
147-
147+
148+ return await super ().on_error (interaction , error , item )
149+
148150 async def update_message (self , interaction : discord .Interaction ) -> None :
149151 """Update the view and edit the message with the new embed."""
150152 self .update_view ()
@@ -168,7 +170,29 @@ async def play_all(self, interaction: discord.Interaction[commands.Bot], button:
168170
169171 @discord .ui .button (label = "Share" , custom_id = "share" , style = discord .ButtonStyle .gray )
170172 async def share (self , interaction : discord .Interaction [commands .Bot ], button : discord .ui .Button ) -> None :
171- await interaction .response .defer ()
173+ modal = BaseModal (
174+ title = "Share Playlist" ,
175+ custom_id = "share_modal" ,
176+ items = [
177+ discord .ui .Label (
178+ text = "User to share with" ,
179+ description = "Select a user to share with" ,
180+ component = discord .ui .UserSelect (
181+ custom_id = "user_select" ,
182+ placeholder = "Select a user to share with" ,
183+ required = True
184+ ),
185+ )
186+ ]
187+ )
188+ await interaction .response .send_modal (modal )
189+ await modal .wait ()
190+
191+ user = modal .values .get ("user_select" )
192+ if not user :
193+ return
194+
195+ await interaction .client .get_command ("playlist share" )(self .primary_view .ctx , user [0 ], self .name )
172196
173197 @discord .ui .button (label = "Export" , custom_id = "export" , style = discord .ButtonStyle .gray )
174198 async def export (self , interaction : discord .Interaction [commands .Bot ], button : discord .ui .Button ) -> None :
0 commit comments