zfixzyy

i want a discord bot that can check how many people are in VC, i can give my discord token bot ID

Kodari AI
KodariJul 17 at 4:58 pm 1
VCCounterBot
A Discord bot that tracks and reports voice channel member counts. Features include listing all active voice channels with member counts, checking specific voice channels, and displaying total server voice activity. Uses discord.py with slash commands for modern Discord interaction. Supports multiple servers and provides real-time voice channel statistics.

I’ll create a Discord bot that checks voice channel member counts.

Done. Here’s what you’ve got:

Files created:

  • bot.py — Main bot with 3 commands

  • .env — Token storage (edit with your token)

  • requirements.txt — Dependencies

Commands:

Command
Usage
What it does
!vc
!vc
Lists all voice channels with member names and counts
!vctotal
!vctotal
Shows total VC members across the server
!vcin
!vcin General
Checks a specific voice channel by name

To run:

  1. Install Python 3.8+

  2. Edit .env — replace your_discord_bot_token_here with your bot token

  3. pip install -r requirements.txt

  4. python bot.py

The bot will print its invite URL on startup — you’ll need that to invite it to your server. Make sure to enable the voice_states and message_content intents in the Discord Developer Portal under your bot’s settings.

Kodari can make mistakes. Review important code before using.
Files
bot.py
requirements.txt
Code
2 115
bot.py
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv

load_dotenv()

TOKEN = os.getenv('DISCORD_TOKEN')
if not TOKEN:
    raise ValueError("DISCORD_TOKEN not found in .env file")

intents = discord.Intents.default()
intents.voice_states = True
intents.guilds = True
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents, help_command=None)


@bot.event
async def on_ready():
    print(f'Logged in as {bot.user} (ID: {bot.user.id})')
    print(f'Invite URL: https://discord.com/api/oauth2/authorize?client_id={bot.user.id}&permissions=3145728&scope=bot%20applications.commands')
    print('------')


@bot.command(name='vc')
async def voice_channels(ctx):
    """Show all voice channels with member counts."""
    guild = ctx.guild
    if not guild:
        await ctx.send("This command can only be used in a server.")
        return

    voice_channels = guild.voice_channels
    if not voice_channels:
        await ctx.send("This server has no voice channels.")
        return

    embed = discord.Embed(
        title=f"Voice Channels in {guild.name}",
        color=discord.Color.blue()
    )

    total_members = 0
    for channel in voice_channels:
        member_count = len(channel.members)
        total_members += member_count

        if member_count > 0:
            member_names = '\n'.join(
                [m.display_name for m in channel.members[:10]]
            )
            if len(channel.members) > 10:
                member_names += f'\n... and {len(channel.members) - 10} more'
            embed.add_field(
                name=f"🔊 {channel.name} ({member_count})",
                value=member_names or 'No one',
                inline=False
            )

    embed.set_footer(text=f"Total: {total_members} member(s) in voice channels")
    await ctx.send(embed=embed)


@bot.command(name='vctotal')
async def vc_total(ctx):
    """Show total number of people in voice channels."""
    guild = ctx.guild
    if not guild:
        await ctx.send("This command can only be used in a server.")
        return

    total = sum(len(vc.members) for vc in guild.voice_channels)
    await ctx.send(f"🔊 **{total}** member(s) are currently in voice channels.")


@bot.command(name='vcin')
async def vc_in(ctx, *, channel_name: str):
    """Check a specific voice channel by name."""
    guild = ctx.guild
    if not guild:
        await ctx.send("This command can only be used in a server.")
        return

    channel = discord.utils.get(guild.voice_channels, name=channel_name)
    if not channel:
        await ctx.send(f"Could not find a voice channel named **{channel_name}**.")
        return

    members = channel.members
    if not members:
        await ctx.send(f"🔇 **{channel.name}** is empty.")
        return

    member_list = '\n'.join([f"• {m.display_name}" for m in members])
    await ctx.send(
        f"🔊 **{channel.name}** — {len(members)} member(s)\n{member_list}"
    )


@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, commands.MissingRequiredArgument):
        await ctx.send(f"Usage: `!{ctx.command.name} {ctx.command.signature}`")
    elif isinstance(error, commands.CommandNotFound):
        pass
    else:
        print(f"Error in {ctx.command}: {error}")


if __name__ == '__main__':
    bot.run(TOKEN)