Search code examples
pythondiscorddiscord.py

Get id of voice channel where bot is connected to


I Want to get the voice channel ID of the voice channel where the bot is connected to. is there any command for it ?


Solution

  • You are able to access discord.ext.commands.Bot's Voice Clients, which can allow you to see voice activity.

    from discord.utils import get
    
    @client.command(name="voice")
    async def voice(ctx):
        voice_client = get(client.voice_clients, guild=ctx.guild)
    
        if not voice_client:
            return await ctx.reply("I am not currently connected to a voice channel!")
    
        voice_channel = voice_client.channel
        voice_channel_id = voice_channel.id