Combining slash commands with prefix commands #8242
-
And again, hello everyone! I have always wondered if it is possible to combine slash commands with the most common commands? Well, like the most common commands are commands by prefixes. Is it possible to combine them together? If yes, can you give an example? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can use hybrid_commands to use préfixed and slash commands at the same time |
Beta Was this translation helpful? Give feedback.
-
Hybrid CommandsThe Defining hybrid commandsSimilar to the @bot.hybrid_command()
async def hello(ctx, member: discord.Member):
await ctx.send(f"Hello {member}") Now this command works as both a text command as well as a slash command. In order for this to appear as slash command, you should sync your command tree using DocumentationThe documentation for hybrid commands is here |
Beta Was this translation helpful? Give feedback.
-
never knew that thanks @abrarahmad1 |
Beta Was this translation helpful? Give feedback.
Hybrid Commands
The
ext.commands
extension provides a feature called "Hybrid Commands" that allow you to define a command that doubles as both a prefix command as well as an application (slash) command.Defining hybrid commands
Similar to the
@command
decorator, In order to define a hybrid command, you can use the@hybrid_command
decorator. Example:Now this command works as both a text command as well as a slash command. In order for this to appear as slash command, you should sync your command tree using
bot.tree.sync()
function.Documentation
The documentation for hybrid commands is h…