Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4f6846a
:sparkles: register slash command groups
zunda-arrow Dec 31, 2021
1ab7454
:sparkles: i think it works
zunda-arrow Dec 31, 2021
c9afe66
:fire: remove code that probably didn't do anything
zunda-arrow Dec 31, 2021
9c98a3b
:twisted_rightwards_arrows: Merge remote-tracking branch 'upstream/ma…
zunda-arrow Jan 1, 2022
1671c32
:memo: added amazing docs
zunda-arrow Jan 1, 2022
d4ec8c3
:memo: added docs for Group and SubGroup
zunda-arrow Jan 1, 2022
b1bb921
:memo: add command groups to the interaction guide
zunda-arrow Jan 2, 2022
fa8945e
:skull: fix typo
zunda-arrow Jan 2, 2022
0a34539
:speech_balloon: fix spelling
zunda-arrow Jan 2, 2022
3df8c95
:bug: fix doc building issue
zunda-arrow Jan 2, 2022
98144f3
:recycle: Apply suggestions from code review
zunda-arrow Jan 2, 2022
8e32994
:art: requsted changes
zunda-arrow Jan 2, 2022
04defab
:twisted_rightwards_arrows: Merge branch 'command_groups' of https://…
zunda-arrow Jan 2, 2022
76ab618
:art: changed SubGroup name to Subgroup
zunda-arrow Jan 2, 2022
c8b88d6
:art: Update pincer/commands/groups.py
zunda-arrow Jan 2, 2022
7bda8d1
:art: Update pincer/commands/groups.py
zunda-arrow Jan 2, 2022
edc4d00
:art: Update pincer/middleware/interaction_create.py
zunda-arrow Jan 2, 2022
c5469a9
:art: switched to recursion for finding command options and made hash…
zunda-arrow Jan 2, 2022
9ebd0b1
:twisted_rightwards_arrows: Merge branch 'command_groups' of https://…
zunda-arrow Jan 2, 2022
aecd019
:recycle: improve interaction name resolution
zunda-arrow Jan 3, 2022
2e2408b
:art: suggesession from trag1c
zunda-arrow Jan 3, 2022
8813619
:zap: improved built register to not care about ClientCommandStructure
zunda-arrow Jan 3, 2022
93cc9c0
:art: Update pincer/commands/commands.py
zunda-arrow Jan 4, 2022
1e3032e
:art: added missing return type __get_local_registered_commands
zunda-arrow Jan 4, 2022
5164932
:art: fix get_local_registered_commands typehint
zunda-arrow Jan 5, 2022
3d4bb87
Merge branch 'main' into command_groups
Enderchief Jan 7, 2022
958fa90
:art: Apply suggestions from code review
zunda-arrow Jan 7, 2022
aec6bc4
:art: Update pincer/commands/groups.py
zunda-arrow Jan 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/api/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ Message Components

.. autoclass:: ActionRow()
.. autoclass:: Button()
:inherited-members:
.. autoclass:: LinkButton()
.. autoclass:: ButtonStyle()
.. autoclass:: SelectMenu()
:inherited-members:
.. autoclass:: SelectOption()
.. autoclass:: _Component()

.. autofunction:: button
:decorator:
.. autofunction:: select_menu
:decorator:
.. autofunction:: component
:decorator:

Command Groups
~~~~~~~~~~~~~~
.. currentmodule:: pincer.commands.groups

.. autoclass:: Group()
.. autoclass:: Subgroup()
18 changes: 3 additions & 15 deletions docs/api/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,12 @@ GatewayDispatch
Gateway
-------

Dispatcher
Gateway
~~~~~~~~~~

.. attributetable:: Dispatcher

.. autoclass:: Dispatcher()
:exclude-members: __handler_manager, __dispatcher

Heartbeat
---------

Heartbeat
~~~~~~~~~

.. attributetable:: Heartbeat
.. attributetable:: Gateway

.. autoclass:: Heartbeat()
:exclude-members: __send
.. autoclass:: Gateway()

Http
----
Expand Down
7 changes: 0 additions & 7 deletions docs/api/objects/guild.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,6 @@ InviteStageInstance

.. autoclass:: InviteStageInstance()

InviteMetadata
~~~~~~~~~~~~~~

.. attributetable:: InviteMetadata

.. autoclass:: InviteMetadata()

Invite
~~~~~~

Expand Down
2 changes: 2 additions & 0 deletions docs/api/pincer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Client
Exceptions
----------

.. currentmodule:: pincer.exceptions

.. autoexception:: PincerError()

.. autoexception:: InvalidPayload()
Expand Down
65 changes: 65 additions & 0 deletions docs/interactions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,68 @@ You can also dynamically set the selectable options.
@select_menu
async def select_menu(values: List[str]):
return f"{values[0]} selected"


Subcommands and Subcommand Groups
---------------------------------
To nest commands, Pincer organizes them into :class:`~pincer.commands.groups.Group` and
:class:`~pincer.commands.groups.Subgroup` objects. Group and Subgroup names must only consist of
lowercase letters and underscores.


This chart shows the organization of nested commands:

.. code-block::

If you use a group:

group name
command name

If you use a group and sub group:

group name
subgroup name
command name

Organizing commands like this is also valid:

group name
subgroup name
command name
command name

:class:`~pincer.commands.groups.Group` and :class:`~pincer.commands.groups.Subgroup` are set to the parent in a @command
decorator to nest a command inside of them. They are not available for User Commands and Message Commands.

.. code-block:: python

from pincer.commands import Group, Subgroup
...

class Bot(Client):

command_group = Group("command_group")
command_sub_group = Subgroup("command_sub_group", parent=a_command_group)

@command(parent=command_group)
def command_group_command():
pass

@command(parent=command_sub_group)
def command_sub_group_command():
pass

# Creating these commands is valid because there is no top-level command or group
# with the same name.
@command
def command_group_command():
pass
@command
def command_sub_group():
pass

# This command is not valid because there is a group with the same name.
@command
def a_command_group():
pass
14 changes: 4 additions & 10 deletions pincer/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
# Copyright Pincer 2021-Present
# Full MIT License can be found in `LICENSE` at the project root.

from .commands import (
command,
user_command,
message_command,
ChatCommandHandler,
hash_app_command,
hash_app_command_params,
)
from .commands import command, user_command, message_command, ChatCommandHandler
from .arg_types import (
CommandArg,
Description,
Expand All @@ -23,12 +16,13 @@
ActionRow, Button, ButtonStyle, ComponentHandler, SelectMenu, SelectOption,
component, button, select_menu, LinkButton
)
from .groups import Group, Subgroup

__all__ = (
"ActionRow", "Button", "ButtonStyle", "ChannelTypes",
"ChatCommandHandler", "Choice", "Choices", "CommandArg",
"ComponentHandler", "Description", "LinkButton", "MaxValue", "MinValue",
"Modifier", "SelectMenu", "SelectOption", "button", "command", "component",
"hash_app_command", "hash_app_command_params", "message_command",
"select_menu", "user_command"
"message_command",
"select_menu", "user_command", "Group", "Subgroup"
)
Loading