Why aren't my tree commands updating in my Discord bot despite adding the guild ID?

I’ve been following a tutorial that suggests including the guild ID to ensure the tree commands update with each instance of the bot running, but this hasn’t resolved my issue. The tree commands are still not reflecting the changes or the new commands that I’ve added.

Here’s a snippet of my current bot implementation:

import discord
from discord import app_commands
from discord.ext import commands
import config

TOKEN = config.bot_token
bot = commands.Bot(command_prefix='!', intents=discord.Intents.all())
all_users = []

@bot.event
async def on_ready():
    await bot.tree.sync(guild=discord.Object(id=YOUR_GUILD_ID))
    print(f'{bot.user} has started!')

@bot.tree.command(name='add_user', description='Add a user')
async def add_user(interaction: discord.Interaction):
    user = interaction.user.name
    all_users.append(user)
    await interaction.response.send_message(f'User {user} added!')

bot.run(TOKEN)

After launching the bot, I see these logs:

INFO: Connected to Discord!
INFO: {bot_user} has connected!

However, when I check my Discord server, the commands still don’t show any updates.

I encountered a similar problem before, and it might be due to caching issues with Discord. Try removing the guild ID when syncing the tree commands, this should register them globally instead of just to one guild, and sometimes fixes synchronization problems. Ensure you also have the latest version of the discord.py library, as older versions might have bugs affecting command updates. If the issue persists, consider re-registering all commands by clearing any cached commands in the bot’s configuration.