You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add in hybrid slash commands
Still relatively untested. Needs a lot of polish.
* feat: simulate specific slash restrains
* fix: oops, scope is weird
* fix: handle no options correctly
* feat: add use_slash_command_msg argument
* docs: add docs for hybrid command manager
* docs: add snippet for hybrid cmds in guide
* docs: finialize docs for hybrid commands
* fix: properly set x_id properties
* docs: adjust title of hybrid command section
* fix: handle dummy base command functions
* fix: parse subcommands correctly
* feat: add silence_autocomplete_errors
* fix: make options not keyword-only
This threw the prefixed command parser in for a loop.
* fix: use more logic to determine right kind of kind
* fix: properly handle keyword only
* feat: add support for aliases
* fix: add aliases to base commands too
* refactor: black learns how to not be dumb
* feat: remove hybrid command dm app permission handling
This wasn't matching slash command behavior
---------
Co-authored-by: Astrea49 <25420078+Astrea49@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/src/Guides/03 Creating Commands.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -520,3 +520,38 @@ There also is `on_command` which you can overwrite too. That fires on every inte
520
520
If your bot is complex enough, you might find yourself wanting to use custom models in your commands.
521
521
522
522
To do this, you'll want to use a string option, and define a converter. Information on how to use converters can be found [on the converter page](/Guides/08 Converters).
523
+
524
+
## I Want To Make A Prefixed/Text Command Too
525
+
526
+
You're in luck! You can use a hybrid command, which is a slash command that also gets converted to an equivalent prefixed command under the hood.
527
+
528
+
Hybrid commands are their own extension, and require [prefixed commands to set up beforehand](/interactions.py/Guides/26 Prefixed Commands). After that, use the `setup` function in the `hybrid_commands` extension in your main bot file.
529
+
530
+
Your setup can (but doesn't necessarily have to) look like this:
531
+
532
+
```python
533
+
import interactions
534
+
from interactions.ext import prefixed_commands as prefixed
535
+
from interactions.ext import hybrid_commands as hybrid
536
+
537
+
bot = interactions.Client(...) # may want to enable the message content intent
538
+
prefixed.setup(bot) # normal step for prefixed commands
539
+
hybrid.setup(bot) # note its usage AFTER prefixed commands have been set up
540
+
```
541
+
542
+
To actually make slash commands, simply replace `@slash_command` with `@hybrid_slash_command`, and `SlashContext` with `HybridContext`, like so:
543
+
544
+
```python
545
+
from interactions.ext.hybrid_commands import hybrid_slash_command, HybridContext
Suggesting you are using the default mention settings for your bot, you should be able to run this command by `@BotPing my_command`.
553
+
554
+
As you can see, the only difference between hybrid commands and slash commands, from a developer perspective, is that they use `HybridContext`, which attempts
555
+
to seamlessly allow using the same context for slash and prefixed commands. You can always get the underlying context via `inner_context`, though.
556
+
557
+
Of course, keep in mind that support two different types of commands is hard - some features may not get represented well in prefixed commands, and autocomplete is not possible at all.
0 commit comments