音乐和/或命令错误discord.py

2024-03-29 10:02:13 发布

您现在位置:Python中文网/ 问答频道 /正文

您好,我的机器人中有音乐和/系统,但我的机器人搜索歌曲花费的时间太长,因此我收到错误交互失败。这是我的代码:

@slash.slash()
@commands.cooldown(1,6,commands.BucketType.channel)
async def igraj(ctx, *, url):
   voicetrue = ctx.guild.me.voice
   
   if voicetrue is None:
       await ctx.author.voice.channel.connect()

   player = music.get_player(guild_id=ctx.guild.id)
   if not player:
       player = music.create_player(ctx, ffmpeg_error_betterfix=False)
   if not ctx.voice_client.is_playing():
       await player.queue(url, search=True)
       song = await player.play()
       desc = f'Igram {song.name}'
       embed = discord.Embed(description = desc, colour=0xf1c40f)
       await ctx.reply(embed=embed)

   else:
       song = await player.queue(url, search=True)
       embed=discord.Embed(description=f'{song.name} je v cakalni vrsti!', colour=0xf1c40f)
       await ctx.send(embed=embed)

有没有什么方法可以像groovy一样加快搜索速度,或者发出交互不会失败的命令? 如果搜索时间太长,我会得到一个错误,他没有连接到语音