简体   繁体   中英

How can I solve a TypeError when deploying my Bot to Heroku?

I tried to create a bot that plays music. After deploying it to Heroku I get the following error :

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

I tried to host the bot from my computer and it works fine. However it's not working when I am trying to host it on Heroku.

Here is my code:

@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}")

Heroku is not the best host if you are looking to deploy a Music Discord Bot, especially when you use FFMPEG. While there is a way, it takes a lot of work to implement. I recommend using a VPN such as Vultr, if you don't want to play you can use PenguinBots, or ShockNodes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM