Discord Bot Join Voice Channel

Viewed 1964

I want my Discord bot to join Voice Channel, but I am running into a problem that whenever I want it to join VC nothing happens - even no errors. I have tried other solutions from SO/Git but none of them worked for me (one of them below):

client = commands.Bot(command_prefix=get_prefix)
@client.command()
async def join(ctx):
    channel = ctx.author.voice.channel
    await channel.connect()
2 Answers

You forgot something.

Line 4 needs to be

channel = client.get_channel(ctx.author.voice.channel.id)
await channel.connect()

I know you have already solved your issue, but I'll show you how I solved it anyway, especially if you ever use @client.event.

I'm not sure if this will work, but have a try. Firstly, I went into my terminal and used pip install PyNaCl. Then I used await ctx.author.voice.channel.connect()

From there, you can play your audio file. Though first, I'd install ffmpeg just in case. Just keep this in mind, but anyways, congratulations on finding a solution!

Related