Skip to content

Instantly share code, notes, and snippets.

@Kakarot-2000
Created February 26, 2021 10:04
Show Gist options
  • Save Kakarot-2000/9c2b327f52de9cc1933cf21bde7bc5b9 to your computer and use it in GitHub Desktop.
Save Kakarot-2000/9c2b327f52de9cc1933cf21bde7bc5b9 to your computer and use it in GitHub Desktop.
@bot.command(name='join', help='Tells the bot to join the voice channel')
async def join(ctx):
if not ctx.message.author.voice:
await ctx.send("{} is not connected to a voice channel".format(ctx.message.author.name))
return
else:
channel = ctx.message.author.voice.channel
await channel.connect()
@bot.command(name='leave', help='To make the bot leave the voice channel')
async def leave(ctx):
voice_client = ctx.message.guild.voice_client
if voice_client.is_connected():
await voice_client.disconnect()
else:
await ctx.send("The bot is not connected to a voice channel.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment