@Mr. Affinity any error in @commands.command(name='play', aliases=['p']) async def…
- User
@Mr. Affinity any error in
@commands.command(name='play', aliases=['p']) async def _play(self, ctx: commands.Context, *, search: str): """Plays a song from YouTube or adds it to queue if already playing."""
codeif not ctx.voice_state.voice: await ctx.invoke(self._join) async with ctx.typing(): try: sources = await YTDLSource.search_source(ctx, search) if not sources: return await ctx.send('No results found.') song = { 'title': sources[0]['title'], 'url': sources[0]['url'], 'duration': sources[0].get('duration', 'N/A'), 'duration_seconds': sources[0].get('duration_seconds', 0), 'requester': ctx.author, 'channel': ctx.channel, 'thumbnail': sources[0].get('thumbnail'), 'uploader': sources[0].get('uploader') } await ctx.voice_state.songs.put(song) await ctx.send(f'Added to queue: **{song["title"]}**') except Exception as e: await ctx.send(f'Error searching for song: {str(e)}') print(f"Play command error: {e}") - Assistant