import asyncio from discord.ext import commands from discord import app_commands # define Bot with **needed** parameters bot = commands.Bot(command_prefix="some_prefix", intents=some_intents_definition) # You can now use `@bot.tree.command()` as a decorator: @bot.tree.command() async def my_command(interaction: discord.Interaction) -> None: await interaction.response.send_message("Hello from my command!") ### NOTE: the above is a global command, see the `main()` func below: # we can even use Groups group = app_commands.Group(name="some-parent", description="description") @group.command() async def my_subcommand(interaction: discord.Interaction) -> None: await interaction.response.send_message("hello from the subcommand!") bot.tree.add_command(group, guild=discord.Object(id=...)) async def main(): async with bot: # do you setup stuff if you need it here, then: bot.tree.copy_global_to(guild=discord.Object(id=...)) # we copy the global commands we have to a guild, this is optional await bot.start(MY_TOKEN) # We still need to sync this tree somehow, but you can make a command as discussed already.