Discord bot slash commands not reflecting recent modifications and additions

I’m creating a Discord bot but I’m facing an issue where the slash commands aren’t updating as expected. According to a tutorial, I should include my guild ID to ensure the tree updates for every instance, but unfortunately, this hasn’t resolved my problem. The commands are not accepting the new inputs I’ve integrated and any commands I’ve recently added are completely missing from the Discord interface.

import discord
from discord import app_commands
from discord.ext import commands
import config
import profiles
import teams
import activities

TOKEN = config.discord_token
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
all_profiles = []
all_teams = []

bot.is_synced = False
bot.is_loaded = False

@bot.event
async def on_ready():
    await bot.wait_until_ready()
    if not bot.is_synced:
        await bot.tree.sync(guild=discord.Object(id=1143632695503638528))
        bot.is_synced = True
    if not bot.is_loaded:
        bot.is_loaded = True
    print(f'{bot.user} is operational now!')

@bot.tree.command(name="register_profile", description="Register a new user profile")
async def register_profile(interaction: discord.Interaction):
    username = interaction.user.name
    new_profile = profiles.Profile(username)
    all_profiles.append(new_profile)
    await interaction.response.send_message(f'Profile for "{username}" has been created successfully')

@bot.tree.command(name="setup_team", description="Create a team with yourself as the founder")
async def setup_team(interaction: discord.Interaction, team_name: str):
    username = interaction.user.name
    user_profile = None
    for profile in all_profiles:
        if profile.name == username:
            user_profile = profile
            break

    if user_profile is None:
        await interaction.response.send_message(f'No profile found for "{username}"')
        return

    new_team = teams.Team(team_name)
    user_profile.joinTeam(new_team)
    all_teams.append(new_team)
    await interaction.response.send_message(f'Team <@{new_team.name}> has been created!')

bot.run(TOKEN)

After launching the bot, I saw the following logs:

2023-10-20 14:21:24 INFO discord.client logging in using static token
2023-10-20 14:21:25 INFO discord.gateway Shard ID None has connected to Gateway
EventBot#1586 is operational now!

However, when I check the slash commands in the Discord server, only a few of the previous commands are visible, and they do not include the updated parameters I added.

Restart your Discord client completely - sounds dumb but cached slash commands cause this all the time. Also don’t mix global and guild commands, that’ll mess things up. Try removing the guild parameter from sync() temporarily to test if global commands work better.

Check if you’ve got global commands from older bot versions that are overriding your guild commands. I hit this exact problem when switching between global and guild syncing during development. Discord prioritizes global commands over guild ones when names clash. Clear all global commands first with await bot.tree.clear_commands(guild=None) then await bot.tree.sync() before your guild sync. Also make sure you’re not running multiple bot instances at once - I’ve done that and it screws up syncing completely. Your logs look fine but Discord’s API is slow to update. Even guild commands can take 10-15 minutes to show up.

Had the same problem last month - Discord’s command cache is incredibly stubborn. Even when you’re syncing to your guild, global commands might be interfering or old cached versions are still hanging around. Try adding a short delay before syncing - I threw in await asyncio.sleep(1) right before the sync call and it worked. Also check if you’ve got global commands that might conflict by running bot.tree.clear_commands(guild=None) before your guild sync. Discord can take up to an hour to fully update commands on their end, especially if you’ve been hammering it with changes. Test in a different server temporarily - if the commands show up there, you’ll know it’s caching rather than your code.