async def _play(self, ctx: commands.Context, *, url: str): # This might happen if play is invoked from another coroutine if not hasattr(ctx, "voice_context"): ctx.voice_context = self.get_voice_context(ctx) if not ctx.voice_context.voice: await ctx.invoke(self._join) try: source = await AsyncAudioSource.create(ctx, url, self.metadata_cache) except YTDLException as e: await ctx.send(f"Nothing found for url {url}...") except Exception as e: LOG.error(f"Error creating audio source: {e}") else: track = Track(source) # If queue contains items, send queued msg if ctx.voice_context.is_playing or len(ctx.voice_context.tracks) > 0: await ctx.send(f"Queued up {track.source.title} !") await ctx.voice_context.tracks.put(track)
async def cog_before_invoke(self, ctx: commands.Context): ctx.voice_context = self.get_voice_context(ctx)