Hey everyone! I’m trying to build a bot for Discord that can modify voice channel names using a command. The voice channel starts with name “0” and I want it to go up by one each time someone uses the command.
import discord
from discord.ext import commands
# Bot configuration
BOT_TOKEN = 'YOUR_BOT_TOKEN_HERE'
TARGET_CHANNEL_ID = 'YOUR_CHANNEL_ID_HERE'
# Initialize counter
number = 0
# Setup bot with required 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 increase counter and rename channel
async def rename_voice_channel(target_channel):
global number
number += 1
await target_channel.edit(name=f"Room {number}")
# Command to trigger the counter
@bot.command()
async def add(ctx):
voice_room = bot.get_channel(int(TARGET_CHANNEL_ID))
if voice_room:
await rename_voice_channel(voice_room)
await ctx.send("Channel name has been updated successfully!")
else:
await ctx.send("Could not locate the voice channel.")
# Ready event
@bot.event
async def on_ready():
print(f'Bot is online as {bot.user}')
# Start the bot
bot.run(BOT_TOKEN)
I left out the actual tokens for security reasons. The problem is when I run the $add command nothing happens at all. Not sure what I’m missing here. Any ideas what could be wrong?
Yeah, Discord’s API hammers channel name changes with rate limits, but there’s a smarter way to do this.
Skip wrestling with Discord’s limits and manual counter tracking. I’ve built similar systems - the trick is using an automation platform that handles the logic and state for you.
You want something that keeps the counter persistent, manages Discord API calls properly, and maybe triggers from multiple sources beyond just commands. Think workflows that track counter state, auto-handle rate limiting, and add features like daily resets or usage stats.
Coding it manually works, but you’ll hit problems: server restarts kill your counter, rate limiting breaks things, and you’re stuck handling every error case yourself.
Latenode handles all this automation stuff - connects straight to Discord’s API, keeps state between runs, and deals with rate limiting smoothly. Build the whole workflow visually and add features easily.
Check it out: https://latenode.com
check your console for errors when u run the command - that’s where you’ll see what’s wrong. make sure the channel ID is wrapped in quotes as a string, not an integer. that can break things. i’d throw some print statements in the add function to see if it’s even getting called.
Had the same problem when I started with Discord bots. It’s usually rate limiting - Discord only lets you change channel names twice every 10 minutes. If you’ve been testing the command over and over, you’re probably hitting that limit. Discord won’t even tell you when this happens. Wait 10-15 minutes and try again. Also check your bot has “Manage Channels” permission and make sure your TARGET_CHANNEL_ID is right. Turn on developer mode, right-click the channel, and copy the ID to double-check. Your code looks good though.
Your bot probably isn’t getting the command. Check if it has the right permissions first - ‘Send Messages’ and ‘Use Slash Commands’ for application commands. Make sure it can actually see the channel you’re typing in too. I had the same problem and found out my bot was missing basic text permissions in some channels. Throw some debug prints in your add command function to see if it’s even firing. Also double-check your bot token is right and it’s actually connected to your server. Test with something simple like making it send a message first.