Bots 如何让机器人加入特定的语音频道?(discord.py)

Bots 如何让机器人加入特定的语音频道?(discord.py),bots,discord,discord.py,Bots,Discord,Discord.py,我正在尝试创建一个discord机器人,当被调用时,它将加入作者所在的语音频道 以下是我所拥有的: @client.command(aliases=["join"]) async def join_voice(self, ctx): channel = ctx.author.voice.channel if channel: print(channel.id) await channel.connect() 当我加入语音频道并键入命令时,我收到以

我正在尝试创建一个discord机器人,当被调用时,它将加入作者所在的语音频道

以下是我所拥有的:

@client.command(aliases=["join"])
async def join_voice(self, ctx):
    channel = ctx.author.voice.channel
    if channel:
        print(channel.id)
        await channel.connect()
当我加入语音频道并键入命令时,我收到以下错误:

Ignoring exception in command join_voice:
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 790, in invoke
    await self.prepare(ctx)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 751, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 670, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\ext\commands\core.py", line 516, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.

此命令是否位于cog/扩展中?看起来上下文是作为self传递的,只有当函数是类函数时才需要self。如果要在主文件中声明此命令,则只需添加签名即可
异步def连接语音(ctx):