Jakaboi
Jakaboi

Reputation: 309

Python - How do I make a join command

I'm trying to create a ".join" command for my bot but everything I've tried didn't work & I tried a ton of things

Here's something I've tried, I tried it in a few other ways too:

@client.command(pass_context=True)
async def join(ctx):
 channel=ctx.message.author.voice.VoiceChannel

 await client.join_VoiceChannel(channel)

It gives this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'VoiceChannel'

Upvotes: 0

Views: 874

Answers (2)

daaarwiin
daaarwiin

Reputation: 147

join_voice_channel

works for older versions of discord.py

This code block should work:

@client.command(pass_context=True)
async def join(ctx):
    message = ctx.message
    channel_id = ctx.message.author.voice.channel.id
    channel = client.get_channel(channel_id)
    await channel.connect()

Upvotes: 1

user10938973
user10938973

Reputation:

You use join_voice_channel to make the bot join a voice channel as it says in the Async docs Try this:

@client.command(pass_context=True)
async def join(ctx):
    author=ctx.message.author
    await bot.join_voice_channel(author.voice_channel)

Upvotes: 0

Related Questions