@@ -226,12 +226,25 @@ async def vc_join(self, ctx: Context) -> None:
226226 return
227227
228228 async with ctx .typing ():
229- if not ctx .author .voice or not ctx .author .voice .channel :
230- await ctx .reply (':x: | You are not in a voice channel!' )
231- return
232- await ctx .author .voice .channel .connect (cls = wavelink .Player )
229+ success = await self .do_join (ctx )
230+
231+ if not success :
232+ await ctx .reply (':x: | There was an error when trying to join the voice channel' )
233+ return
233234 await ctx .reply (':white_check_mark: | Successfully joined the voice channel!' )
234235
236+ async def do_join (self , ctx : Context ) -> bool :
237+ if not ctx .author .voice or not ctx .author .voice .channel :
238+ await ctx .reply (':x: | You are not in a voice channel!' )
239+ return False
240+ try :
241+ await ctx .author .voice .channel .connect (cls = wavelink .Player )
242+ except Exception as e :
243+ _log .exception ('Ignoring exception in do_join:' , exc_info = e )
244+ return False
245+ else :
246+ return True
247+
235248 @music .command (name = 'play' )
236249 @commands .cooldown (1 , 15 , commands .BucketType .member )
237250 async def vc_play (self , ctx : Context , source : wavelink .TrackSource | None = None , * , query : str ) -> None :
@@ -252,7 +265,11 @@ async def vc_play(self, ctx: Context, source: wavelink.TrackSource | None = None
252265 player = ctx .voice_client
253266
254267 if not player or not isinstance (player , wavelink .Player ):
255- await ctx .invoke (self .vc_join )
268+ success = await self .do_join (ctx )
269+ if not success :
270+ await ctx .reply (':x: | There was an error when trying to join the voice channel' )
271+ return
272+ await ctx .reinvoke ()
256273 return
257274
258275 if not ctx .author .voice or not ctx .author .voice .channel or ctx .author .voice .channel .id != player .channel .id :
0 commit comments