I've got a bot that I want to listen to a command only if the user calling it is in the same voice channel. Here is my code.
@bot.command(name='leave', help='Disconnects the bot.')
async def leave(ctx):
user_channel = ctx.message.author.voice.channel
bot_channel = ctx.guild.voice_client
print(user_channel)
print(bot_channel)
if user_channel == bot_channel:
client = ctx.guild.voice_client
await client.disconnect()
else:
await ctx.send('You have to be connected to the same voice channel to disconnect me.')
However, my issue is that those print lines return different strings. User channel: vc 2, Bot channel: <\discord.voice_client.VoiceClient object at 0x000001D4E168FB20> How can I get them both to read the ID of the voice channel so I can compare them?