【问题标题】:How can I solve a TypeError when deploying my Bot to Heroku?将 Bot 部署到 Heroku 时如何解决 TypeError?
【发布时间】:2021-08-12 12:01:38
【问题描述】:

我尝试创建一个播放音乐的机器人。将其部署到 Heroku 后,我收到以下 错误

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: _hook() takes 2 positional arguments but 3 were given

我尝试从我的计算机托管机器人,它运行良好。但是,当我尝试在 Heroku 上托管它时它不起作用。

这是我的代码:

@client.command(pass_context=True, aliases=['j', 'joi'])
async def join(ctx):
    channel = ctx.message.author.voice.channel
    voice = get(client.voice_clients, guild=ctx.guild)

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        voice = await channel.connect()

    await voice.disconnect()

    if voice and voice.is_connected():
        await voice.move_to(channel)
    else:
        await channel.connect()
        print(f"The bot has connected to {channel}\n")

    await ctx.send(f"Joined {channel}")

【问题讨论】:

  • 请分享代码!
  • 该错误包含有关_hook() 的内容,但代码似乎没有此内容。您确定您与我们分享了正确的代码吗?
  • 是的,这就是代码,没有像 _hook() 这样的东西

标签: python heroku discord discord.py


【解决方案1】:

如果您希望部署 Music Discord Bot,Heroku 并不是最好的主机,尤其是在您使用 FFMPEG 时。虽然有办法,但实施起来需要做很多工作。我建议使用 Vultr 等 VPN,如果您不想玩,可以使用 PenguinBots 或 ShockNodes。

【讨论】:

    猜你喜欢
    • 2021-06-14
    • 2018-06-06
    • 1970-01-01
    • 2022-01-22
    • 2021-06-29
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 2021-05-13
    相关资源
    最近更新 更多