Discord Bot Command to Modify Voice Channel Name

Issue with voice channel name modification

I’m trying to build a Discord bot that can change a voice channel’s name using a specific command. The voice channel starts with the name “0” and I want it to go up by one number each time I run the command.

import discord
from discord.ext import commands

# Bot configuration
BOT_TOKEN = 'YOUR_BOT_TOKEN_HERE'
TARGET_CHANNEL_ID = 'YOUR_CHANNEL_ID_HERE'

# Counter variable
number = 0

# Bot setup with permissions
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.voice_states = True
bot = commands.Bot(command_prefix='$', intents=intents)

# Function to change channel name
async def modify_channel_title(voice_ch):
    global number
    number += 1
    await voice_ch.edit(name=f"Room {number}")

# Command to trigger the update
@bot.command()
async def update(ctx):
    target_channel = bot.get_channel(int(TARGET_CHANNEL_ID))
    if target_channel:
        await modify_channel_title(target_channel)
        await ctx.send("Channel name has been updated successfully.")
    else:
        await ctx.send("Could not locate the specified channel.")

# Bot ready event
@bot.event
async def on_ready():
    print(f'Bot is online as {bot.user}')
    print(f'Bot ID: {bot.user.id}')
    print('Ready to process commands')

# Start the bot
bot.run(BOT_TOKEN)

When I execute the $update command, nothing seems to happen at all. The bot doesn’t respond and the channel name stays the same. I’m not sure what’s wrong with my code or what steps I should take to fix this problem.

Your bot probably isn’t getting message events. I had the same issue where commands just wouldn’t work at all. Check if your bot’s actually online first - see if the on_ready event prints to console. If that works, it’s likely the message_content intent. You need to enable it in the Discord Developer Portal under your bot’s settings, not just in code. Also check if you’re testing in DMs vs a server channel - some intents act differently. Try adding a simple test command like @bot.command() async def test(ctx): await ctx.send('working') to make sure the bot processes commands before you mess with the channel stuff.

make sure ur bot has permissions to manage channels. also, there’s a rate limit on changing names, so do it less often!

Your bot probably doesn’t have the right permissions. Make sure it has “Manage Channels” permission for the server or that specific channel. Discord also limits channel name changes to twice per 10 minutes, so if you’re testing this a lot, you might be hitting that wall. Add some error handling around voice_ch.edit() to see what error you’re actually getting. Also double-check that TARGET_CHANNEL_ID is set as a string in your code since you’re converting it to int later.