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.