-
I currently have a bot running regular commands, it begins using:
However, the app_commands requires us to initiate the bot in an entirely different way. How can we combine both of them in the same bot? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 4 replies
-
Hello, the bot = commands.Bot(...)
@bot.tree.command()
async def example(interaction: discord.Interaction) -> None:
... Commands inside Cogs also work out of the box and are added and removed with the cog: class Example(commands.Cog):
@discord.app_commands.command()
async def example(self, interaction: discord.Interaction) -> None:
...
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Example()) # Commands are added to bot.tree, can be used and synced to Discord by you Syncing the tree to Discord is still your responsibility when using the commands extension. If you'd like to have the same commands available as text and slash commands there is a new |
Beta Was this translation helpful? Give feedback.
-
@LostLuma how do i define the variables like guild for slashcommand in your first code block above? |
Beta Was this translation helpful? Give feedback.
-
@LostLuma sorry but i don't understand how to use |
Beta Was this translation helpful? Give feedback.
-
@LostLuma This is what i'm trying, but failing:
|
Beta Was this translation helpful? Give feedback.
-
@LostLuma i am unable to find this slash command in this guild, so "finding the slash command" is failing... |
Beta Was this translation helpful? Give feedback.
-
I tried sync too, but still unable to see the command in the guild. This is the complete code, i am not sure which part has error, please help....! really stuck!
|
Beta Was this translation helpful? Give feedback.
-
@LostLuma thankyou! works now! :) |
Beta Was this translation helpful? Give feedback.
Hello, the
Bot
andAutoShardedBot
classes already come with aCommandTree
attached that you can add commands to:Commands inside Cogs also work out of the box and are added and removed with the cog:
Syncing the tree to Discord is still your responsibility when using the commands e…