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.