Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programming a Discord bot with Python- How do I make it join a voice channel?

I want to make the bot join the voice channel that I'm in when prompted. Here's what I have:

@client.event
async def on_message(message):
  if message.content.startswith('.join'):
    channel = 775902254951301125
    await channel.connect()

It doesn't seem to work, any tips?

like image 582
Carter Michaelis Avatar asked Dec 22 '25 18:12

Carter Michaelis


1 Answers

I think this is what you're looking for!

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

That was pulled straight from this video which was just a google search away.

like image 151
goose.mp4 Avatar answered Dec 24 '25 06:12

goose.mp4



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!