From f4667798016df91b6a2141a48906dc69a84c9c5e Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Tue, 4 Oct 2022 22:31:02 +0100 Subject: [PATCH 01/32] fix: fix docs building warnings & errors --- docs/events.rst | 26 +++++++---------- docs/faq.rst | 6 ++-- docs/quickstart.rst | 2 +- docs/utils.rst | 2 +- interactions/api/dispatch.py | 8 ++--- interactions/api/models/channel.py | 1 + interactions/api/models/guild.py | 2 +- interactions/api/models/member.py | 6 ++-- interactions/api/models/misc.py | 3 ++ interactions/client/context.py | 6 ++-- interactions/client/models/command.py | 1 + interactions/client/models/component.py | 39 ++++++++++++++++++------- interactions/utils/utils.py | 2 +- 13 files changed, 60 insertions(+), 44 deletions(-) diff --git a/docs/events.rst b/docs/events.rst index a9bf65a3b..9699056d0 100644 --- a/docs/events.rst +++ b/docs/events.rst @@ -19,18 +19,18 @@ Generally, you can listen to an event like this: # possibility 1 @bot.event - async def on_(...): + async def on_xxx(...): ... # do smth # possibility 2 - @bot.event(name="on_") + @bot.event(name="on_xxx") async def you_are_free_to_name_this_as_you_want(...): ... # do smth bot.start() -```` represents the Discord event name - but lowercase and any spaces replaced with ``_``. +``xxx`` represents the Discord event name - but with lowercase characters and any spaces replaced with ``_``. For example: @@ -74,7 +74,7 @@ as long as you don't absolutely need it. Event: ``on_start`` -^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^ This event fires only when the bot is started. This function takes no arguments. @@ -83,7 +83,7 @@ This function takes no arguments. Unlike ``on_ready``, this event will never be dispatched more than once. Event: ``on_interaction`` -^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^ This event fires on any interaction (commands, components, autocomplete and modals). The function needs one argument. It will have the type ``CommandContext`` or ``ComponentContext``. @@ -93,7 +93,7 @@ recommend using this event unless you have experience with it. Event: ``on_command`` -^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^ This event fires on any Application Command (slash command + context menu command) used. The function takes in one argument of the type ``CommandContext``. @@ -113,7 +113,7 @@ The function takes in two arguments, one of the type ``CommandContext``, and the Event: ``on_component`` -^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^ This event fires on any Component used (for now, those are Buttons and Select Menus). The function takes in one argument of the type ``ComponentContext``. @@ -141,9 +141,6 @@ The function takes in one argument of the type ``CommandContext``. You will have to get all values yourself and check what modal was used when using this event. -Additionally, if you struggle with getting the values, you can check -:ref:`how it is handled internally `. - After this, let us look at events from the Discord API. @@ -151,17 +148,17 @@ Discord API Events ****************** Events in this section do not match the name needed to put into the function. Please check -:ref:`above ` for how to get the correct name. +:ref:`above` for how to get the correct name. -There are a lot of events dispatched by the Discord API. All of those can be found `here`_. +There are a lot of events dispatched by the Discord API. All of those can be found `here `_. The events ``HELLO``, ``RESUMED``, ``RECONNECT``, ``INVALID SESSION`` and ``TYPING START`` are not dispatched by the library. ``TYPING START`` will be included in the raw socket create event. You can also listen for it if you choose to subclass the WebSocketClient -The event ``VOICE STATE UPDATE`` can be only received with the voice :ref:`Extension `. +The event ``VOICE STATE UPDATE`` can be only received with the :ref:`voice extension`. Let's now have a look at a few events: @@ -197,6 +194,3 @@ The function takes in one argument of the type ``GuildMember``. The argument has the same methods as a normal ``Member`` object, except the methods *do not take in a guild id*. Please keep that in mind when using this event. - - -.. _here: https://Discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events diff --git a/docs/faq.rst b/docs/faq.rst index 789b56a66..66cc6e908 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -206,7 +206,7 @@ You can get those object via the ``get_channel()`` and ``get_guild()`` methods o "``ctx.send got an unexpected keyword argument: files``"! Why? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is not supported due to an decision of the core developer team. There are two ways to do it: @@ -215,7 +215,7 @@ There are two ways to do it: "``ctx.send got an unexpected keyword argument: embed``"! Why? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is quite simple: The argument ``embed`` got deprecated by Discord. The new naming is ``embeds``. @@ -244,7 +244,7 @@ You can additionally get the exact reason for why the exception occurred with `` My message content is always empty! How can I fix this? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This happens because you did not enable the intent for message content. Enable it on the developer portal and add it into the ``Client`` definition as the following: ``bot = interactions.Client(..., intents=interactions.Intents.DEFAULT | interactions.Intents.GUILD_MESSAGE_CONTENT)`` diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 79cc69380..176a6bb0c 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -99,7 +99,7 @@ Let's take a look now at what is happening here: Now, let's create our first slash command: -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python diff --git a/docs/utils.rst b/docs/utils.rst index c450ac2e7..0cb7c5922 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -1,7 +1,7 @@ .. currentmodule:: interactions The ``get`` utility method -================ +========================== .. automodule:: interactions.utils.get :members: diff --git a/interactions/api/dispatch.py b/interactions/api/dispatch.py index c35197d46..1dbb80e21 100644 --- a/interactions/api/dispatch.py +++ b/interactions/api/dispatch.py @@ -29,10 +29,10 @@ def dispatch(self, __name: str, *args, **kwargs) -> None: :param __name: The name of the event to dispatch. :type __name: str - :param *args: Multiple arguments of the coroutine. - :type *args: list[Any] - :param **kwargs: Keyword-only arguments of the coroutine. - :type **kwargs: dict + :param \*args: Multiple arguments of the coroutine. + :type \*args: list[Any] + :param \**kwargs: Keyword-only arguments of the coroutine. + :type \**kwargs: dict """ for event in self.events.get(__name, []): converters: dict diff --git a/interactions/api/models/channel.py b/interactions/api/models/channel.py index 4c5144efa..a84420b3f 100644 --- a/interactions/api/models/channel.py +++ b/interactions/api/models/channel.py @@ -1875,6 +1875,7 @@ async def get_permissions_for(self, member: "Member") -> Permissions: @define() class Thread(Channel): """An object representing a thread. + .. note:: This is a derivation of the base Channel, since a thread can be its own event. diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index 5bd09847e..565352eed 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -594,7 +594,7 @@ async def add_member_role( This method adds a role to a member. :param role: The role to add. Either ``Role`` object or role_id - :type role Union[Role, int, Snowflake] + :type role: Union[Role, int, Snowflake] :param member_id: The id of the member to add the roles to :type member_id: Union[Member, int, Snowflake] :param reason?: The reason why the roles are added diff --git a/interactions/api/models/member.py b/interactions/api/models/member.py index febd5e813..61436969b 100644 --- a/interactions/api/models/member.py +++ b/interactions/api/models/member.py @@ -590,15 +590,15 @@ async def has_permissions( guild_id: Optional[Union[int, Snowflake, "Guild"]] = MISSING, operator: str = "and", ) -> bool: - """ + r""" Returns whether the member has the permissions passed. .. note:: If the channel argument is present, the function will look if the member has the permissions in the specified channel. If the argument is missing, then it will only consider the member's guild permissions. - :param *permissions: The list of permissions - :type *permissions: Union[int, Permissions] + :param \*permissions: The list of permissions + :type \*permissions: Union[int, Permissions] :param channel: The channel where to check for permissions :type channel: Channel :param guild_id: The id of the guild diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 34e15e208..b0e19d173 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -189,6 +189,7 @@ def __hash__(self) -> int: class AutoModMetaData(DictSerializerMixin): """ A class object used to represent the AutoMod Action Metadata. + .. note:: This is not meant to be instantiated outside the Gateway. @@ -220,10 +221,12 @@ class AutoModKeywordPresetTypes(IntEnum): class AutoModAction(DictSerializerMixin): """ A class object used for the ``AUTO_MODERATION_ACTION_EXECUTION`` event. + .. note:: This is not to be confused with the GW event ``AUTO_MODERATION_ACTION_EXECUTION``. This object is not the same as that dispatched object. Moreover, that dispatched object name will be ``AutoModerationAction`` + .. note:: The metadata can be omitted depending on the action type. diff --git a/interactions/client/context.py b/interactions/client/context.py index eb4a52246..0de83d169 100644 --- a/interactions/client/context.py +++ b/interactions/client/context.py @@ -317,11 +317,11 @@ async def popup(self, modal: Modal) -> dict: async def has_permissions( self, *permissions: Union[int, Permissions], operator: str = "and" ) -> bool: - """ + r""" Returns whether the author of the interaction has the permissions in the given context. - :param *permissions: The list of permissions - :type *permissions: Union[int, Permissions] + :param \*permissions: The list of permissions + :type \*permissions: Union[int, Permissions] :param operator: The operator to use to calculate permissions. Possible values: `and`, `or`. Defaults to `and`. :type operator: str :return: Whether the author has the permissions diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index c92d3cabf..94f5efeef 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -169,6 +169,7 @@ class Permission(DictSerializerMixin): type=interactions.PermissionType.USER, permission=True, ) + :ivar int id: The ID of the permission. :ivar PermissionType type: The type of permission. :ivar bool permission: The permission state. ``True`` for allow, ``False`` for disallow. diff --git a/interactions/client/models/component.py b/interactions/client/models/component.py index c7ff13809..8e8a7f7da 100644 --- a/interactions/client/models/component.py +++ b/interactions/client/models/component.py @@ -42,13 +42,16 @@ def __setattr__(self, key, value) -> None: @define() class SelectOption(ComponentMixin): """ - A class object representing the select option of a select menu. - The structure for a select option: :: + A class object representing the select option of a select menu. The structure for a select option: + + .. code-block:: python + interactions.SelectOption( label="I'm a cool option. :)", value="internal_option_value", description="some extra info about me! :D", ) + :ivar str label: The label of the select option. :ivar str value: The returned value of the select option. :ivar Optional[str] description?: The description of the select option. @@ -70,13 +73,16 @@ def __attrs_post_init__(self): @define() class SelectMenu(ComponentMixin): """ - A class object representing the select menu of a component. - The structure for a select menu: :: + A class object representing the select menu of a component. The structure for a select menu: + + .. code-block:: python + interactions.SelectMenu( options=[interactions.SelectOption(...)], placeholder="Check out my options. :)", custom_id="menu_component", ) + :ivar ComponentType type: The type of select menu. Always defaults to ``3``. :ivar str custom_id: The customized "ID" of the select menu. :ivar List[SelectOption] options: The list of select options in the select menu. @@ -102,13 +108,16 @@ def __attrs_post_init__(self) -> None: @define() class Button(ComponentMixin): """ - A class object representing the button of a component. - The structure for a button: :: + A class object representing the button of a component. The structure for a button: + + .. code-block:: python + interactions.Button( style=interactions.ButtonStyle.DANGER, label="Delete", custom_id="delete_message", ) + :ivar ComponentType type: The type of button. Always defaults to ``2``. :ivar ButtonStyle style: The style of the button. :ivar str label: The label of the button. @@ -140,6 +149,7 @@ class Component(ComponentMixin): .. note:: ``components`` is only applicable if an ActionRow is supported, otherwise ActionRow-less will be opted. ``list`` is in reference to the class. + .. warning:: This object class is only inferred upon when the gateway is processing back information involving a component. Do not use this object for sending. @@ -192,8 +202,10 @@ def __attrs_post_init__(self): @define() class TextInput(ComponentMixin): """ - A class object representing the text input of a modal. - The structure for a text input: :: + A class object representing the text input of a modal. The structure for a text input: + + .. code-block:: python + interactions.TextInput( style=interactions.TextStyleType.SHORT, label="Let's get straight to it: what's 1 + 1?", @@ -201,6 +213,7 @@ class TextInput(ComponentMixin): min_length=2, max_length=3, ) + :ivar ComponentType type: The type of input. Always defaults to ``4``. :ivar TextStyleType style: The style of the input. :ivar str custom_id: The custom Id of the input. @@ -229,8 +242,10 @@ def __attrs_post_init__(self): @define() class Modal(ComponentMixin): """ - A class object representing a modal. - The structure for a modal: :: + A class object representing a modal. The structure for a modal: + + .. code-block:: python + interactions.Modal( title="Application Form", custom_id="mod_app_form", @@ -267,7 +282,9 @@ class ActionRow(ComponentMixin): only. The structure for an action row: - ..code-block:: python + + .. code-block:: python + # "..." represents a component object. # Method 1: interactions.ActionRow(...) diff --git a/interactions/utils/utils.py b/interactions/utils/utils.py index 912782015..63d98fdb3 100644 --- a/interactions/utils/utils.py +++ b/interactions/utils/utils.py @@ -132,7 +132,7 @@ async def command(ctx): await ctx.send("Components:", components=spread_to_rows(b1, b2, s1, b3, b4)) .. note:: - You can only pass in :class:`ActionRow`s, :class:`Button`s, and :class:`SelectMenu`s, but in any order. + You can only pass in :class:`.ActionRow`, :class:`.Button`, and :class:`.SelectMenu`, but in any order. :param \*components: The components to spread. :type \*components: Union[ActionRow, Button, SelectMenu] From dd3440e19904e7788238ecfad0efe931401422c1 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 00:09:25 +0100 Subject: [PATCH 02/32] feat: change overall docs layout and remove pages that do not need to be documented --- docs/api.cache.rst | 7 ------- docs/api.dispatch.rst | 7 ------- docs/api.enums.rst | 7 ------- docs/api.error.rst | 7 ------- docs/api.gateway.rst | 13 ------------- docs/api.http.rst | 4 ++++ docs/api.models.rst | 3 ++- docs/api.rst | 43 +++++++++++++++++++------------------------ docs/models.rst | 4 ++-- docs/utils.get.rst | 7 +++++++ docs/utils.rst | 15 ++++++--------- docs/utils.utils.rst | 7 +++++++ 12 files changed, 47 insertions(+), 77 deletions(-) delete mode 100644 docs/api.cache.rst delete mode 100644 docs/api.dispatch.rst delete mode 100644 docs/api.enums.rst delete mode 100644 docs/api.error.rst delete mode 100644 docs/api.gateway.rst create mode 100644 docs/utils.get.rst create mode 100644 docs/utils.utils.rst diff --git a/docs/api.cache.rst b/docs/api.cache.rst deleted file mode 100644 index b6f1d6e76..000000000 --- a/docs/api.cache.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. currentmodule:: interactions - -Client Cache -============ - -.. automodule:: interactions.api.cache - :members: diff --git a/docs/api.dispatch.rst b/docs/api.dispatch.rst deleted file mode 100644 index 914f360db..000000000 --- a/docs/api.dispatch.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. currentmodule:: interactions - -Dispatching -=========== - -.. automodule:: interactions.api.dispatch - :members: diff --git a/docs/api.enums.rst b/docs/api.enums.rst deleted file mode 100644 index 73a56785b..000000000 --- a/docs/api.enums.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. currentmodule:: interactions - -Enumerable Objects -================== - -.. automodule:: interactions.api.enums - :members: diff --git a/docs/api.error.rst b/docs/api.error.rst deleted file mode 100644 index d37a54d88..000000000 --- a/docs/api.error.rst +++ /dev/null @@ -1,7 +0,0 @@ -.. currentmodule:: interactions - -Error Exceptions -================ - -.. automodule:: interactions.api.error - :members: diff --git a/docs/api.gateway.rst b/docs/api.gateway.rst deleted file mode 100644 index 8d96bd1a6..000000000 --- a/docs/api.gateway.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. currentmodule:: interactions - -Gateway -======= - -.. automodule:: interactions.api.gateway - :members: - -.. automodule:: interactions.api.gateway.client - :members: - -.. automodule:: interactions.api.gateway.heartbeat - :members: diff --git a/docs/api.http.rst b/docs/api.http.rst index e4cef068d..c7bd41f87 100644 --- a/docs/api.http.rst +++ b/docs/api.http.rst @@ -3,6 +3,10 @@ HTTP ==== +.. warning:: + This page shows internal functions that you should not use unless you know how to use them. + Most of these functions should have their own implementation in the different Models of the library. + .. autoclass:: interactions.api.http.route.Route :members: diff --git a/docs/api.models.rst b/docs/api.models.rst index 32c5386f6..b29773452 100644 --- a/docs/api.models.rst +++ b/docs/api.models.rst @@ -1,6 +1,6 @@ .. currentmodule:: interactions -Model Objects +API Models ============= .. toctree:: @@ -20,3 +20,4 @@ Model Objects api.models.team.rst api.models.user.rst api.models.webhook.rst + enums.rst diff --git a/docs/api.rst b/docs/api.rst index ae3cdc806..17beec48c 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3,10 +3,7 @@ API Reference ============= -This page outlines the API wrapper of discord-interactions. - -Interactions -************ +This page outlines the API reference of interactions.py. .. toctree:: :maxdepth: 2 @@ -16,40 +13,38 @@ Interactions .. toctree:: :maxdepth: 2 - :caption: Frameworks/Commands + :caption: API Models - ext.rst - context.rst - utils.rst + api.models.rst .. toctree:: :maxdepth: 2 - :caption: Model/Design + :caption: Commands & Components models.rst - enums.rst - -Discord API -*********** .. toctree:: :maxdepth: 2 - :caption: Client Connections + :caption: Context - api.gateway.rst - api.http.rst + context.rst .. toctree:: :maxdepth: 2 - :caption: Model/Design + :caption: Utilities - api.cache.rst - api.enums.rst - api.models.rst + utils.rst .. toctree:: - :maxdepth: 2 - :caption: Events + :maxdepth: 1 + :caption: HTTP + + api.http.rst + +.. toctree:: + :maxdepth: 1 + :caption: External Framework + + ext.rst + - api.dispatch.rst - api.error.rst diff --git a/docs/models.rst b/docs/models.rst index 949fdd220..e9720e452 100644 --- a/docs/models.rst +++ b/docs/models.rst @@ -1,7 +1,7 @@ .. currentmodule:: interactions -Interaction Models -================== +Commands & Components +===================== .. toctree:: :maxdepth: 2 diff --git a/docs/utils.get.rst b/docs/utils.get.rst new file mode 100644 index 000000000..8aa45432f --- /dev/null +++ b/docs/utils.get.rst @@ -0,0 +1,7 @@ +.. currentmodule:: interactions + +The ``get`` utility method +========================== + +.. automodule:: interactions.utils.get + :members: diff --git a/docs/utils.rst b/docs/utils.rst index 0cb7c5922..5caae4821 100644 --- a/docs/utils.rst +++ b/docs/utils.rst @@ -1,13 +1,10 @@ .. currentmodule:: interactions -The ``get`` utility method -========================== - -.. automodule:: interactions.utils.get - :members: - Utilities -========================== +========== + +.. toctree:: + :maxdepth: 2 -.. automodule:: interactions.utils.utils - :members: + utils.get.rst + utils.utils.rst diff --git a/docs/utils.utils.rst b/docs/utils.utils.rst new file mode 100644 index 000000000..bd52147e8 --- /dev/null +++ b/docs/utils.utils.rst @@ -0,0 +1,7 @@ +.. currentmodule:: interactions + +Utility Functions +================= + +.. automodule:: interactions.utils.utils + :members: From 745b5878389aa96eee3d5d74a1ecf22c819f6efa Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 00:09:37 +0100 Subject: [PATCH 03/32] fix: rectify indenting --- docs/quickstart.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 176a6bb0c..076a7a7de 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -4,7 +4,7 @@ Quickstart Installing ********** -**discord-interactions** is a :ref:`Python library ` for the Discord Application Programming Interface. (API) +**interactions.py** is a :ref:`Python library ` for the Discord Application Programming Interface. (API) A library in Python has to be installed through the `pip` file. Run this in your terminal/command line in order to install our library: @@ -561,7 +561,7 @@ Responding to a Modal interaction You can respond to a modal the same way as you would respond to a normal ``chat-input`` command, except your function has an extra argument for the text what was put into the modal. Adding v2 Permissions -^^^^^^^^^^^^^^^^^^^^^ +********************* v2 permissions consist of the ``default_member_permissions`` and ``dm_permission`` keyword arguments. Similar to adding privileged intents, you add permissions (like admin-only, ``BAN_MEMBERS``-only, etc.) as follows: @@ -625,7 +625,7 @@ Likewise, setting ``dm_permission`` to ``True`` makes it usable in DMs. Just to global commands. Guild commands with this argument will have no effect. Utilities -^^^^^^^^^ +********* You can use the following utilities to help you with your commands: From fc2713b2cdd6bfc9867866600989ab6243774d16 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 15:14:26 +0100 Subject: [PATCH 04/32] feat: remove private methods from docs --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 33869f8a6..569990b33 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -78,7 +78,7 @@ exclude_patterns = ["_build"] # This autodocs private attrs and also fixes wrong sort -autodoc_default_options = {"member-order": "bysource", "private-members": True} +autodoc_default_options = {"member-order": "bysource"} # -- Options for HTML output ------------------------------------------------- From 0814313ef3e6151b7edb99b9b2786bd409ead034 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 16:26:30 +0100 Subject: [PATCH 05/32] update bot.py --- interactions/client/bot.py | 234 +++++++++++++------------------------ 1 file changed, 82 insertions(+), 152 deletions(-) diff --git a/interactions/client/bot.py b/interactions/client/bot.py index fa74e4bd8..9235b9464 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -46,30 +46,15 @@ class Client: """ A class representing the client connection to Discord's gateway and API via. WebSocket and HTTP. - :param token: The token of the application for authentication and connection. - :type token: str - :param intents?: Allows specific control of permissions the application has when connected. In order to use multiple intents, the | operator is recommended. Defaults to ``Intents.DEFAULT``. - :type intents?: Optional[Intents] - :param shards?: Dictates and controls the shards that the application connects under. - :type shards?: Optional[List[Tuple[int]]] - :param presence?: Sets an RPC-like presence on the application when connected to the Gateway. - :type presence?: Optional[ClientPresence] - :param default_scope?: Sets the default scope of all commands. - :type default_scope?: Optional[Union[int, Guild, List[int], List[Guild]]] - :param disable_sync?: Controls whether synchronization in the user-facing API should be automatic or not. - :type disable_sync?: Optional[bool] - :param logging?: Set to ``True`` to enable debug logging or set to a log level to use a specific level - :type logging?: Optional[Union[bool, logging.DEBUG, logging.INFO, logging.NOTSET, logging.WARNING, logging.ERROR, logging.CRITICAL]] - - :ivar AbstractEventLoop _loop: The asynchronous event loop of the client. - :ivar HTTPClient _http: The user-facing HTTP connection to the Web API, as its own separate client. - :ivar WebSocketClient _websocket: An object-orientation of a websocket server connection to the Gateway. - :ivar Intents _intents: The Gateway intents of the application. Defaults to ``Intents.DEFAULT``. - :ivar Optional[List[Tuple[int]]] _shard: The list of bucketed shards for the application's connection. - :ivar Optional[ClientPresence] _presence: The RPC-like presence shown on an application once connected. - :ivar str _token: The token of the application used for authentication when connecting. - :ivar Optional[Dict[str, ModuleType]] _extensions: The "extensions" or cog equivalence registered to the main client. - :ivar Application me?: The application representation of the client. + :param str token: The token of the application for authentication and connection. + :param Optional[Intents] intents: Allows specific control of permissions the application has when connected. In order to use multiple intents, the ``|`` operator is recommended. Defaults to :attr:`.Intents.DEFAULT`. + :param Optional[List[Tuple[int]]] shards: Dictates and controls the shards that the application connects under. + :param Optional[ClientPresence] presence: Sets an RPC-like presence on the application when connected to the Gateway. + :param Optional[Union[int, Guild, List[int], List[Guild]]] default_scope: Sets the default scope of all commands. + :param Optional[bool] disable_sync: Controls whether synchronization in the user-facing API should be automatic or not. + :param Optional[Union[bool, logging.DEBUG, logging.INFO, logging.NOTSET, logging.WARNING, logging.ERROR, logging.CRITICAL]] logging: Set to ``True`` to enable debug logging or set to a log level to use a specific level + + :ivar Application me: The application representation of the client. """ def __init__( @@ -178,10 +163,8 @@ async def __compare_sync( """ Compares an application command during the synchronization process. - :param data: The application command to compare. - :type data: dict - :param pool: The "pool" or list of commands to compare from. - :type pool: List[dict] + :param dict data: The application command to compare. + :param List[dict] pool: The "pool" or list of commands to compare from. :return: Whether the command has changed or not. :rtype: bool """ @@ -723,10 +706,10 @@ def event( A decorator for listening to events dispatched from the Gateway. - :param coro: The coroutine of the event. - :type coro: Optional[Callable[..., Coroutine]] - :param name(?): The name of the event. If not given, this defaults to the coroutine's name. - :type name: Optional[str] + Documentation on how to listen to specific events can be found :ref:`here`. + + :param Optional[Callable[..., Coroutine]] coro: The coroutine of the event. + :param Optional[str] name: The name of the event. If not given, this defaults to the coroutine's name. :return: A callable response. :rtype: Callable[..., Any] """ @@ -749,13 +732,12 @@ async def change_presence(self, presence: ClientPresence) -> None: """ A method that changes the current client's presence on runtime. - .. note:: + .. note:: There is a ratelimit to using this method (5 per minute). As there's no gateway ratelimiter yet, breaking this ratelimit will force your bot to disconnect. - :param presence: The presence to change the bot to on identify. - :type presence: ClientPresence + :param ClientPresence presence: The presence to change the bot to on identify. """ await self._websocket._update_presence(presence) @@ -981,19 +963,10 @@ def command( .. code-block:: python - @command(name="command-name", description="this is a command.") + @bot.command(name="command-name", description="this is a command.") async def command_name(ctx): ... - You are also able to establish it as a message or user command by simply passing - the ``type`` kwarg field into the decorator: - - .. code-block:: python - - @command(type=interactions.ApplicationCommandType.MESSAGE, name="Message Command") - async def message_command(ctx): - ... - The ``scope`` kwarg field may also be used to designate the command in question applicable to a guild or set of guilds. @@ -1002,7 +975,7 @@ async def message_command(ctx): .. code-block:: python - @command(name="kick", description="Kick a user.", default_member_permissions=interactions.Permissions.BAN_MEMBERS | interactions.Permissions.KICK_MEMBERS) + @bot.command(name="kick", description="Kick a user.", default_member_permissions=interactions.Permissions.BAN_MEMBERS | interactions.Permissions.KICK_MEMBERS) async def kick(ctx, user: interactions.Member): ... @@ -1010,33 +983,23 @@ async def kick(ctx, user: interactions.Member): .. code-block:: python - @command(name="sudo", description="this is an admin-only command.", default_member_permissions=interactions.Permissions.ADMINISTRATOR) + @bot.command(name="sudo", description="this is an admin-only command.", default_member_permissions=interactions.Permissions.ADMINISTRATOR) async def sudo(ctx): ... .. note:: If ``default_member_permissions`` is not given, this will default to anyone that is able to use the command. - :param type?: The type of application command. Defaults to :meth:`interactions.enums.ApplicationCommandType.CHAT_INPUT` or ``1``. - :type type?: Optional[Union[str, int, ApplicationCommandType]] - :param name: The name of the application command. This *is* required but kept optional to follow kwarg rules. - :type name: Optional[str] - :param description?: The description of the application command. This should be left blank if you are not using ``CHAT_INPUT``. - :type description?: Optional[str] - :param scope?: The "scope"/applicable guilds the application command applies to. - :type scope?: Optional[Union[int, Guild, List[int], List[Guild]]] - :param options?: The "arguments"/options of an application command. This should be left blank if you are not using ``CHAT_INPUT``. - :type options?: Optional[Union[Dict[str, Any], List[Dict[str, Any]], Option, List[Option]]] - :param name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. - :type name_localizations?: Optional[Dict[Union[str, Locale], str]] - :param description_localizations?: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. - :type description_localizations?: Optional[Dict[Union[str, Locale], str]] - :param default_member_permissions?: The permissions bit value of ``interactions.api.model.flags.Permissions``. If not given, defaults to :meth:`interactions.api.model.flags.Permissions.USE_APPLICATION_COMMANDS` or ``2147483648`` - :type default_member_permissions?: Optional[Union[int, Permissions]] - :param dm_permission?: The application permissions if executed in a Direct Message. Defaults to ``True``. - :type dm_permission?: Optional[bool] - :param default_scope?: Whether the scope of the command is the default scope set in the client. Defaults to ``True``. - :type default_scope?: bool + :param Optional[Union[str, int, ApplicationCommandType]] type: The type of application command. Defaults to :attr:`.ApplicationCommandType.CHAT_INPUT`. + :param Optional[str] name: The name of the application command. This *is* required but kept optional to follow kwarg rules. + :param Optional[str] description: The description of the application command. This should be left blank if you are not using ``CHAT_INPUT``. + :param Optional[Union[int, Guild, List[int], List[Guild]]] scope: The "scope"/applicable guilds the application command applies to. + :param Optional[Union[Dict[str, Any], List[Dict[str, Any]], Option, List[Option]]] options: The "arguments"/options of an application command. This should be left blank if you are not using ``CHAT_INPUT``. + :param Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :param Optional[Dict[Union[str, Locale], str]] description_localizations: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. + :param Optional[Union[int, Permissions]] default_member_permissions: The permissions bit value of :class:`.Permissions`. If not given, defaults to :attr:`.Permissions.USE_APPLICATION_COMMANDS` + :param Optional[bool] dm_permission: The application permissions if executed in a Direct Message. Defaults to ``True``. + :param Optional[bool] default_scope: Whether the scope of the command is the default scope set in the client. Defaults to ``True``. :return: A callable response. :rtype: Callable[[Callable[..., Coroutine]], Command] """ @@ -1080,27 +1043,19 @@ def message_command( .. code-block:: python - @message_command(name="Context menu name") + @bot.message_command(name="Context menu name") async def context_menu_name(ctx): ... The ``scope`` kwarg field may also be used to designate the command in question applicable to a guild or set of guilds. - :param name: The name of the application command. - :type name: Optional[str] - :param scope?: The "scope"/applicable guilds the application command applies to. Defaults to ``None``. - :type scope?: Optional[Union[int, Guild, List[int], List[Guild]]] - :param default_permission?: The default permission of accessibility for the application command. Defaults to ``True``. - :type default_permission?: Optional[bool] - :param name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. - :type name_localizations?: Optional[Dict[Union[str, Locale], str]] - :param default_member_permissions?: The permissions bit value of ``interactions.api.model.flags.Permissions``. If not given, defaults to :meth:`interactions.api.model.flags.Permissions.USE_APPLICATION_COMMANDS` or ``2147483648`` - :type default_member_permissions?: Optional[Union[int, Permissions]] - :param dm_permission?: The application permissions if executed in a Direct Message. Defaults to ``True``. - :type dm_permission?: Optional[bool] - :param default_scope?: Whether the scope of the command is the default scope set in the client. Defaults to ``True``. - :type default_scope?: bool + :param Optional[str] name: The name of the application command. + :param Optional[Union[int, Guild, List[int], List[Guild]]] scope: The "scope"/applicable guilds the application command applies to. Defaults to ``None``. + :param Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :param Optional[Union[int, Permissions]] default_member_permissions: The permissions bit value of :class:`.Permissions`. If not given, defaults to :attr:`.Permissions.USE_APPLICATION_COMMANDS` + :param Optional[bool] dm_permission: The application permissions if executed in a Direct Message. Defaults to ``True``. + :param Optional[bool] default_scope: Whether the scope of the command is the default scope set in the client. Defaults to ``True``. :return: A callable response. :rtype: Callable[[Callable[..., Coroutine]], Command] """ @@ -1137,27 +1092,19 @@ def user_command( .. code-block:: python - @user_command(name="Context menu name") + @bot.user_command(name="Context menu name") async def context_menu_name(ctx): ... The ``scope`` kwarg field may also be used to designate the command in question applicable to a guild or set of guilds. - :param name: The name of the application command. - :type name: Optional[str] - :param scope?: The "scope"/applicable guilds the application command applies to. Defaults to ``None``. - :type scope?: Optional[Union[int, Guild, List[int], List[Guild]]] - :param default_permission?: The default permission of accessibility for the application command. Defaults to ``True``. - :type default_permission?: Optional[bool] - :param name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. - :type name_localizations?: Optional[Dict[Union[str, Locale], str]] - :param default_member_permissions?: The permissions bit value of ``interactions.api.model.flags.Permissions``. If not given, defaults to :meth:`interactions.api.model.flags.Permissions.USE_APPLICATION_COMMANDS` or ``2147483648`` - :type default_member_permissions?: Optional[Union[int, Permissions]] - :param dm_permission?: The application permissions if executed in a Direct Message. Defaults to ``True``. - :type dm_permission?: Optional[bool] - :param default_scope?: Whether the scope of the command is the default scope set in the client. Defaults to ``True``. - :type default_scope?: bool + :param Optional[str] name: The name of the application command. + :param Optional[Union[int, Guild, List[int], List[Guild]]] scope: The "scope"/applicable guilds the application command applies to. Defaults to ``None``. + :param Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :param Optional[Union[int, Permissions]] default_member_permissions: The permissions bit value of :class:`.Permissions`. If not given, defaults to :attr:`.Permissions.USE_APPLICATION_COMMANDS` + :param Optional[bool] dm_permission: The application permissions if executed in a Direct Message. Defaults to ``True``. + :param Optional[bool] default_scope: Whether the scope of the command is the default scope set in the client. Defaults to ``True``. :return: A callable response. :rtype: Callable[[Callable[..., Coroutine]], Command] """ @@ -1187,7 +1134,7 @@ def component( .. code-block:: python # Method 1 - @component(interactions.Button( + @bot.component(interactions.Button( style=interactions.ButtonStyle.PRIMARY, label="click me!", custom_id="click_me_button", @@ -1196,15 +1143,14 @@ async def button_response(ctx): ... # Method 2 - @component("custom_id") + @bot.component("custom_id") async def button_response(ctx): ... The context of the component callback decorator inherits the same as of the command decorator. - :param component: The component you wish to callback for. - :type component: Union[str, Button, SelectMenu] + :param Union[str, Button, SelectMenu] component: The component you wish to callback for. :return: A callable response. :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ @@ -1272,7 +1218,7 @@ def autocomplete( .. code-block:: python - @autocomplete(command="command_name", name="option_name") + @bot.autocomplete(command="command_name", name="option_name") async def autocomplete_choice_list(ctx, user_input: str = ""): await ctx.populate([ interactions.Choice(...), @@ -1280,10 +1226,8 @@ async def autocomplete_choice_list(ctx, user_input: str = ""): ... ]) - :param command: The command, command ID, or command name with the option. - :type command: Union[ApplicationCommand, int, str, Snowflake] - :param name: The name of the option to autocomplete. - :type name: str + :param Union[ApplicationCommand, int, str, Snowflake] command: The command, command ID, or command name with the option. + :param str name: The name of the option to autocomplete. :return: A callable response. :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ @@ -1321,7 +1265,7 @@ def modal( .. code-block:: python - @modal(interactions.Modal( + @bot.modal(interactions.Modal( interactions.TextInput( style=interactions.TextStyleType.PARAGRAPH, custom_id="how_was_your_day_field", @@ -1329,14 +1273,13 @@ def modal( placeholder="Well, so far...", ), )) - async def modal_response(ctx): + async def modal_response(ctx, how_was_your_day_field: str): ... The context of the modal callback decorator inherits the same as of the component decorator. - :param modal: The modal or custom_id of modal you wish to callback for. - :type modal: Union[Modal, str] + :param Union[Modal, str] modal: The modal or custom_id of modal you wish to callback for. :return: A callable response. :rtype: Callable[[Callable[..., Coroutine]], Callable[..., Coroutine]] """ @@ -1354,14 +1297,10 @@ def load( "Loads" an extension off of the current client by adding a new class which is imported from the library. - :param name: The name of the extension. - :type name: str - :param package?: The package of the extension. - :type package?: Optional[str] - :param \*args?: Optional arguments to pass to the extension - :type \**args: tuple - :param \**kwargs?: Optional keyword-only arguments to pass to the extension. - :type \**kwargs?: dict + :param str name: The name of the extension. + :param Optional[str] package: The package of the extension. + :param tuple \*args: Optional arguments to pass to the extension + :param dict \**kwargs: Optional keyword-only arguments to pass to the extension. :return: The loaded extension. :rtype: Optional[Extension] """ @@ -1393,12 +1332,9 @@ def remove( """ Removes an extension out of the current client from an import resolve. - :param name: The name of the extension. - :type name: str - :param remove_commands?: Whether to remove commands before reloading. Defaults to True. - :type remove_commands?: bool - :param package?: The package of the extension. - :type package?: Optional[str] + :param str name: The name of the extension. + :param Optional[bool] remove_commands: Whether to remove commands before reloading. Defaults to ``True``. + :param Optional[str] package: The package of the extension. """ try: _name: str = resolve_name(name, package) @@ -1446,19 +1382,14 @@ def reload( .. warning:: This will remove and re-add application commands, counting towards your daily application - command creation limit, as long as you have the ``remove_commands`` argument set to ``True``, what it is by + command creation limit, as long as you have the ``remove_commands`` argument set to ``True``, which it is by default. - :param name: The name of the extension - :type name: str - :param package?: The package of the extension - :type package?: Optional[str] - :param remove_commands?: Whether to remove commands before reloading. Defaults to True - :type remove_commands?: bool - :param \*args?: Optional arguments to pass to the extension - :type \**args: tuple - :param \**kwargs?: Optional keyword-only arguments to pass to the extension. - :type \**kwargs?: dict + :param str name: The name of the extension + :param Optional[str] package: The package of the extension + :param Optional[bool] remove_commands: Whether to remove commands before reloading. Defaults to True + :param tuple \*args: Optional arguments to pass to the extension + :param dict \**kwargs: Optional keyword-only arguments to pass to the extension. :return: The reloaded extension. :rtype: Optional[Extension] """ @@ -1473,6 +1404,13 @@ def reload( return self.load(name, package, *args, **kwargs) def get_extension(self, name: str) -> Optional[Union[ModuleType, "Extension"]]: + """ + Get an extension based on its name. + + :param str name: Name of the extension. + :return: The found extension. + :rtype: Optional[Union[ModuleType, Extension]] + """ return self._extensions.get(name) async def modify( @@ -1483,10 +1421,8 @@ async def modify( """ Modify the bot user account settings. - :param username?: The new username of the bot - :type username?: Optional[str] - :param avatar?: The new avatar of the bot - :type avatar?: Optional[Image] + :param Optional[str] username: The new username of the bot + :param Optional[Image] avatar: The new avatar of the bot :return: The modified User object :rtype: User """ @@ -1511,18 +1447,12 @@ async def request_guild_members( """ Requests guild members via websocket. - :param guild_id: ID of the guild to get members for. - :type guild_id: Union[Guild, Snowflake, int, str] - :param limit: Maximum number of members to send matching the 'query' parameter. Required when specifying 'query'. - :type limit: Optional[int] - :param query: String that username starts with. - :type query: Optional[str] - :param presences: Used to specify if we want the presences of the matched members. - :type presences: Optional[bool] - :param user_ids: Used to specify which users you wish to fetch. - :type user_ids: Optional[Union[Snowflake, List[Snowflake]]] - :param nonce: Nonce to identify the Guild Members Chunk response. - :type nonce: Optional[str] + :param Union[Guild, Snowflake, int, str] guild_id: ID of the guild to get members for. + :param Optional[int] limit: Maximum number of members to send matching the 'query' parameter. Required when specifying 'query'. + :param Optional[str] query: String that username starts with. + :param Optional[bool] presences: Used to specify if we want the presences of the matched members. + :param Optional[Union[Snowflake, List[Snowflake]]] user_ids: Used to specify which users you wish to fetch. + :param Optional[str] nonce: Nonce to identify the Guild Members Chunk response. """ await self._websocket.request_guild_members( guild_id=int(guild_id.id) if isinstance(guild_id, Guild) else int(guild_id), @@ -1538,7 +1468,6 @@ async def _logout(self) -> None: await self._http._req.close() -# TODO: Implement the rest of cog behaviour when possible. class Extension: """ A class that allows you to represent "extensions" of your code, or @@ -1695,6 +1624,7 @@ def decorator(coro) -> Command: return decorator +@wraps(Client.event) def extension_listener(func: Optional[Coroutine] = None, name: Optional[str] = None): def decorator(func: Coroutine): func.__listener_name__ = name or func.__name__ From a4b753e486b221851aed33e66234de9e0b489e41 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 16:53:56 +0100 Subject: [PATCH 06/32] update context.py and hide inherited members from ClientSerializerMixin --- docs/context.rst | 3 +- interactions/client/context.py | 98 +++++++++++++--------------------- 2 files changed, 39 insertions(+), 62 deletions(-) diff --git a/docs/context.rst b/docs/context.rst index 129a58531..9a068849e 100644 --- a/docs/context.rst +++ b/docs/context.rst @@ -4,5 +4,6 @@ Event Context ============= .. automodule:: interactions.client.context + :inherited-members: ClientSerializerMixin :members: - :inherited-members: + :private-members: diff --git a/interactions/client/context.py b/interactions/client/context.py index 0de83d169..b08f44c8a 100644 --- a/interactions/client/context.py +++ b/interactions/client/context.py @@ -39,7 +39,7 @@ class _Context(ClientSerializerMixin): easily access information presented from any event in a "contextualized" sense. - :ivar Optional[Message] message?: The message data model. + :ivar Optional[Message] message: The message data model. :ivar Member author: The member data model. :ivar User user: The user data model. :ivar Optional[Channel] channel: The channel data model. @@ -125,24 +125,16 @@ async def send( This allows the invocation state described in the "context" to send an interaction response. - :param content?: The contents of the message as a string or string-converted value. - :type content?: Optional[str] - :param tts?: Whether the message utilizes the text-to-speech Discord programme or not. - :type tts?: Optional[bool] - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param embeds?: An embed, or list of embeds for the message. - :type embeds?: Optional[Union[Embed, List[Embed]]] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] - :param components?: A component, or list of components for the message. - :type components?: Optional[Union[ActionRow, Button, SelectMenu, List[Union[ActionRow, Button, SelectMenu]]]] - :param ephemeral?: Whether the response is hidden or not. - :type ephemeral?: Optional[bool] - :param suppress_embeds: Whether embeds are not shown in the message. - :type suppress_embeds: bool - :return: The sent message as an object. - :rtype: Message + :param Optional[str] content: The contents of the message as a string or string-converted value. + :param Optional[bool] tts: Whether the message utilizes the text-to-speech Discord programme or not. + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Optional[Union[Embed, List[Embed]]] embeds: An embed, or list of embeds for the message. + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. + :param Optional[Union[ActionRow, Button, SelectMenu, List[Union[ActionRow, Button, SelectMenu]]]] components: A component, or list of components for the message. + :param Optional[bool] ephemeral: Whether the response is hidden or not. + :param Optional[bool] suppress_embeds: Whether embeds are not shown in the message. + :return: The sent message as a dict. + :rtype: dict """ if ( content is MISSING @@ -223,10 +215,10 @@ async def edit( """ This allows the invocation state described in the "context" to send an interaction response. This inherits the arguments - of the Context ``.send()`` method. + of the :func:`_Context.send` method. - :return: The edited message as an object. - :rtype: Message + :return: The edited message as a dict. + :rtype: dict """ payload = {} @@ -292,8 +284,7 @@ async def popup(self, modal: Modal) -> dict: This "pops up" a modal to present information back to the user. - :param modal: The components you wish to show. - :type modal: Modal + :param Modal modal: The components you wish to show. """ payload: dict = { @@ -320,10 +311,8 @@ async def has_permissions( r""" Returns whether the author of the interaction has the permissions in the given context. - :param \*permissions: The list of permissions - :type \*permissions: Union[int, Permissions] - :param operator: The operator to use to calculate permissions. Possible values: `and`, `or`. Defaults to `and`. - :type operator: str + :param Union[int, Permissions] \*permissions: The list of permissions + :param Optional[str] operator: The operator to use to calculate permissions. Possible values: ``and``, ``or``. Defaults to ``and``. :return: Whether the author has the permissions :rtype: bool """ @@ -342,35 +331,22 @@ async def has_permissions( @define() class CommandContext(_Context): """ - A derivation of :class:`interactions.context.Context` + A derivation of :class:`_Context` designed specifically for application command data. - .. warning:: - The ``guild`` attribute of the base context - is not accessible for any interaction-related events - since the current Discord API schema does not return - this as a value, but instead ``guild_id``. You will - need to manually fetch for this data for the time being. - - You can fetch with ``client.get_guild(guild_id)`` which - will return a JSON dictionary, which you can then use - ``interactions.Guild(**data)`` for an object or continue - with a dictionary for your own purposes. - - :ivar _client: the HTTP client :ivar Snowflake id: The ID of the interaction. :ivar Snowflake application_id: The application ID of the interaction. :ivar InteractionType type: The type of interaction. - :ivar InteractionData data?: The application command data. + :ivar InteractionData data: The application command data. :ivar Optional[Union[Message, Member, User]] target: The target selected if this interaction is invoked as a context menu. :ivar str token: The token of the interaction response. - :ivar Snowflake guild_id?: The ID of the current guild. - :ivar Snowflake channel_id?: The ID of the current channel. + :ivar Snowflake guild_id: The ID of the current guild. + :ivar Snowflake channel_id: The ID of the current channel. :ivar bool responded: Whether an original response was made or not. :ivar bool deferred: Whether the response was deferred or not. - :ivar str locale?: The selected language of the user invoking the interaction. - :ivar str guild_locale?: The guild's preferred language, if invoked in a guild. - :ivar str app_permissions?: Bitwise set of permissions the bot has within the channel the interaction was sent from. + :ivar str locale: The selected language of the user invoking the interaction. + :ivar str guild_locale: The guild's preferred language, if invoked in a guild. + :ivar str app_permissions: Bitwise set of permissions the bot has within the channel the interaction was sent from. :ivar Client client: The client instance that the command belongs to. :ivar Command command: The command object that is being invoked. :ivar Extension extension: The extension the command belongs to. @@ -465,8 +441,7 @@ async def defer(self, ephemeral: Optional[bool] = False) -> None: This "defers" an interaction response, allowing up to a 15-minute delay between invocation and responding. - :param ephemeral?: Whether the deferred state is hidden or not. - :type ephemeral?: Optional[bool] + :param Optional[bool] ephemeral: Whether the deferred state is hidden or not. """ if not self.responded: self.deferred = True @@ -549,8 +524,7 @@ async def populate(self, choices: Union[Choice, List[Choice]]) -> List[Choice]: Only a maximum of ``25`` choices may be presented within an autocomplete option. - :param choices: The choices you wish to present. - :type choices: Union[Choice, List[Choice]] + :param Union[Choice, List[Choice]] choices: The choices you wish to present. :return: The list of choices you've given. :rtype: List[Choice] """ @@ -593,7 +567,7 @@ async def func(): @define() class ComponentContext(_Context): """ - A derivation of :class:`interactions.context.CommandContext` + A derivation of :class:`_Context` designed specifically for component data. """ @@ -685,10 +659,8 @@ async def defer( This "defers" a component response, allowing up to a 15-minute delay between invocation and responding. - :param ephemeral?: Whether the deferred state is hidden or not. - :type ephemeral?: Optional[bool] - :param edit_origin?: Whether you want to edit the original message or send a followup message - :type edit_origin?: Optional[bool] + :param Optional[bool] ephemeral: Whether the deferred state is hidden or not. + :param Optional[bool] edit_origin: Whether you want to edit the original message or send a followup message """ if not self.responded: @@ -715,10 +687,8 @@ async def disable_all_components( r""" Disables all components of the message. - :param respond_to_interaction?: Whether the components should be disabled in an interaction response, default True - :type respond_to_interaction?: Optional[bool] - :param \**other_kwargs?: Additional keyword-arguments to pass to the edit method. This only works when this method is used as interaction response and takes the same arguments as :meth:`interactions.client.context._Context:edit()` - :type \**other_kwargs?: Optional[dict] + :param Optional[bool] respond_to_interaction: Whether the components should be disabled in an interaction response, default True + :param Optional[dict] \**other_kwargs: Additional keyword-arguments to pass to the edit method. This only works when this method is used as interaction response and takes the same arguments as :func:`ComponentContext.edit()` :return: The modified Message :rtype: Message @@ -742,12 +712,18 @@ async def disable_all_components( @property def custom_id(self) -> Optional[str]: + """ + The custom ID of the interacted component. + + :rtype: Optional[str] + """ return self.data.custom_id @property def label(self) -> Optional[str]: """ The label of the interacted button. + :rtype: Optional[str] """ if not self.data.component_type == ComponentType.BUTTON: From a2e87b6df87d0ce78f007faa7a469735418cfca9 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 18:38:55 +0100 Subject: [PATCH 07/32] update client.models --- interactions/client/models/command.py | 82 ++++++++++--------------- interactions/client/models/component.py | 65 ++++++++++---------- interactions/client/models/misc.py | 28 ++++----- 3 files changed, 80 insertions(+), 95 deletions(-) diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index 94f5efeef..44cbcfea2 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -50,7 +50,7 @@ class Choice(DictSerializerMixin): :ivar str name: The name of the choice. :ivar Union[str, int, float] value: The returned value of the choice. - :ivar Optional[Dict[Union[str, Locale], str]] name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :ivar Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. """ name: str = field() @@ -100,18 +100,18 @@ class Option(DictSerializerMixin): :ivar str name: The name of the option. :ivar str description: The description of the option. :ivar bool focused: Whether the option is currently being autocompleted or not. - :ivar Optional[bool] required?: Whether the option has to be filled out. - :ivar Optional[str] value?: The value that's currently typed out, if autocompleting. - :ivar Optional[List[Choice]] choices?: The list of choices to select from. - :ivar Optional[List[Option]] options?: The list of subcommand options included. - :ivar Optional[List[ChannelType]] channel_types?: Restrictive shown channel types, if given. - :ivar Optional[int] min_value?: The minimum value supported by the option. - :ivar Optional[int] max_value?: The maximum value supported by the option. - :ivar Optional[int] min_length?: The minimum length supported by the option. - :ivar Optional[int] max_length?: The maximum length supported by the option. - :ivar Optional[bool] autocomplete?: A status denoting whether this option is an autocomplete option. - :ivar Optional[Dict[Union[str, Locale], str]] name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. - :ivar Optional[Dict[Union[str, Locale], str]] description_localizations?: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. + :ivar Optional[bool] required: Whether the option has to be filled out. + :ivar Optional[str] value: The value that's currently typed out, if autocompleting. + :ivar Optional[List[Choice]] choices: The list of choices to select from. + :ivar Optional[List[Option]] options: The list of subcommand options included. + :ivar Optional[List[ChannelType]] channel_types: Restrictive shown channel types, if given. + :ivar Optional[int] min_value: The minimum value supported by the option. + :ivar Optional[int] max_value: The maximum value supported by the option. + :ivar Optional[int] min_length: The minimum length supported by the option. + :ivar Optional[int] max_length: The maximum length supported by the option. + :ivar Optional[bool] autocomplete: A status denoting whether this option is an autocomplete option. + :ivar Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :ivar Optional[Dict[Union[str, Locale], str]] description_localizations: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. :ivar Optional[str] converter: How the option value is passed to the function, if different than ``name`` """ @@ -195,12 +195,12 @@ class ApplicationCommand(DictSerializerMixin): :ivar Snowflake id: The ID of the application command. :ivar ApplicationCommandType type: The application command type. - :ivar Optional[Snowflake] application_id?: The general application ID of the command itself. - :ivar Optional[Snowflake] guild_id?: The guild ID of the application command. + :ivar Optional[Snowflake] application_id: The general application ID of the command itself. + :ivar Optional[Snowflake] guild_id: The guild ID of the application command. :ivar str name: The name of the application command. :ivar str description: The description of the application command. - :ivar Optional[List[Option]] options?: The "options"/arguments of the application command. - :ivar Optional[bool] default_permission?: The default permission accessibility state of the application command. + :ivar Optional[List[Option]] options: The "options"/arguments of the application command. + :ivar Optional[bool] default_permission: The default permission accessibility state of the application command. :ivar int version: The Application Command version autoincrement identifier. :ivar str default_member_permissions: The default member permission state of the application command. :ivar boolean dm_permission: The application permissions if executed in a Direct Message. @@ -245,10 +245,8 @@ def option( async def my_command(ctx, opt: str): ... - :param description?: The description of the option. Defaults to "No description set". - :type description?: str - :param \**kwargs?: The keyword arguments of the option, same as :class:`Option`. - :type \**kwargs?: dict + :param str description: The description of the option. Defaults to ``No description set``. + :param dict \**kwargs: The keyword arguments of the option, same as :class:`Option`. """ def decorator(coro: Callable[..., Awaitable]) -> Callable[..., Awaitable]: @@ -548,19 +546,13 @@ async def subcommand_group(ctx): If you want to create both subcommands and subcommands with groups, first create the subcommands without groups, then create the subcommands with groups. - :param group?: The name of the group the subcommand belongs to. Defaults to the most recently used group. - :type group?: Optional[str] - :param name?: The name of the subcommand. Defaults to the name of the coroutine. - :type name?: Optional[str] - :param description?: The description of the subcommand. Defaults to the docstring of the coroutine. - :type description?: Optional[str] - :param options?: The options of the subcommand. - :type options?: Optional[List[Option]] - :param name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. - :type name_localizations?: Optional[Dict[Union[str, Locale], str]] - :param description_localizations?: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. - :type description_localizations?: Optional[Dict[Union[str, Locale], str]] - :return: The :class:`interactions.client.models.command.Command` object. + :param Optional[str] group: The name of the group the subcommand belongs to. Defaults to the most recently used group. + :param Optional[str] name: The name of the subcommand. Defaults to the name of the coroutine. + :param Optional[str] description: The description of the subcommand. Defaults to the docstring of the coroutine. + :param Optional[List[Option]] options: The options of the subcommand. + :param Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :param Optional[Dict[Union[str, Locale], str]] description_localizations: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. + :return: The :class:`Command` object. :rtype: Command """ @@ -655,15 +647,11 @@ async def subcommand_group(ctx): If you want to create both subcommands and subcommands with groups, first create the subcommands without groups, then create the subcommands with groups. - :param name?: The name of the group. Defaults to the name of the coroutine. - :type name?: Optional[str] - :param description?: The description of the group. Defaults to the docstring of the coroutine. - :type description?: Optional[str] - :param name_localizations?: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. - :type name_localizations?: Optional[Dict[Union[str, Locale], str]] - :param description_localizations?: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. - :type description_localizations?: Optional[Dict[Union[str, Locale], str]] - :return: The :class:`interactions.client.models.command.Command` object. + :param Optional[str] name: The name of the group. Defaults to the name of the coroutine. + :param Optional[str] description: The description of the group. Defaults to the docstring of the coroutine. + :param Optional[Dict[Union[str, Locale], str]] name_localizations: The dictionary of localization for the ``name`` field. This enforces the same restrictions as the ``name`` field. + :param Optional[Dict[Union[str, Locale], str]] description_localizations: The dictionary of localization for the ``description`` field. This enforces the same restrictions as the ``description`` field. + :return: The :class:`Command` object. :rtype: Command """ @@ -764,8 +752,7 @@ def autocomplete( """ Decorator for creating an autocomplete for the command. - :param name?: The name of the option to autocomplete. Defaults to the name of the coroutine. - :type name?: Optional[str] + :param Optional[str] name: The name of the option to autocomplete. Defaults to the name of the coroutine. :return: The coroutine :rtype: Callable[..., Coroutine] """ @@ -809,8 +796,7 @@ async def command_error(ctx, error): but you can also have additional parameters so that the base or group result (if any) and/or options are passed. - :param coro: The coroutine to be called when an error occurs. - :type coro: Callable[..., Coroutine] + :param Callable[..., Coroutine] coro: The coroutine to be called when an error occurs. """ num_params = len(signature(coro).parameters) @@ -843,7 +829,7 @@ async def __call( param_len, ) # index of *args par_opts = list(params.keys())[ - (num := 2 if self.extension else 1) : ( + (num := 2 if self.extension else 1): ( -1 if last.kind in (last.VAR_POSITIONAL, last.VAR_KEYWORD) else index_of_var_pos ) ] # parameters that are before *args and **kwargs diff --git a/interactions/client/models/component.py b/interactions/client/models/component.py index 8e8a7f7da..b61279937 100644 --- a/interactions/client/models/component.py +++ b/interactions/client/models/component.py @@ -54,9 +54,9 @@ class SelectOption(ComponentMixin): :ivar str label: The label of the select option. :ivar str value: The returned value of the select option. - :ivar Optional[str] description?: The description of the select option. - :ivar Optional[Emoji] emoji?: The emoji used alongside the label of the select option. - :ivar Optional[bool] default?: Whether the select option is the default for the select menu. + :ivar Optional[str] description: The description of the select option. + :ivar Optional[Emoji] emoji: The emoji used alongside the label of the select option. + :ivar Optional[bool] default: Whether the select option is the default for the select menu. """ label: str = field() @@ -86,10 +86,10 @@ class SelectMenu(ComponentMixin): :ivar ComponentType type: The type of select menu. Always defaults to ``3``. :ivar str custom_id: The customized "ID" of the select menu. :ivar List[SelectOption] options: The list of select options in the select menu. - :ivar Optional[str] placeholder?: The placeholder of the select menu. - :ivar Optional[int] min_values?: The minimum "options"/values to choose from the component. - :ivar Optional[int] max_values?: The maximum "options"/values to choose from the component. - :ivar Optional[bool] disabled?: Whether the select menu is unable to be used. + :ivar Optional[str] placeholder: The placeholder of the select menu. + :ivar Optional[int] min_values: The minimum "options"/values to choose from the component. + :ivar Optional[int] max_values: The maximum "options"/values to choose from the component. + :ivar Optional[bool] disabled: Whether the select menu is unable to be used. """ type: ComponentType = field(converter=ComponentType, default=ComponentType.SELECT) @@ -121,10 +121,10 @@ class Button(ComponentMixin): :ivar ComponentType type: The type of button. Always defaults to ``2``. :ivar ButtonStyle style: The style of the button. :ivar str label: The label of the button. - :ivar Optional[Emoji] emoji?: The emoji used alongside the label of the button. - :ivar Optional[str] custom_id?: The customized "ID" of the button. - :ivar Optional[str] url?: The URL route/path of the button. - :ivar Optional[bool] disabled?: Whether the button is unable to be used. + :ivar Optional[Emoji] emoji: The emoji used alongside the label of the button. + :ivar Optional[str] custom_id: The customized "ID" of the button. + :ivar Optional[str] url: The URL route/path of the button. + :ivar Optional[bool] disabled: Whether the button is unable to be used. """ type: ComponentType = field(converter=ComponentType, default=ComponentType.BUTTON) @@ -155,21 +155,21 @@ class Component(ComponentMixin): back information involving a component. Do not use this object for sending. :ivar ComponentType type: The type of component. - :ivar Optional[str] custom_id?: The customized "ID" of the component. - :ivar Optional[bool] disabled?: Whether the component is unable to be used. - :ivar Optional[ButtonStyle] style?: The style of the component. - :ivar Optional[str] label?: The label of the component. - :ivar Optional[Emoji] emoji?: The emoji used alongside the label of the component. - :ivar Optional[str] url?: The URl route/path of the component. - :ivar Optional[List[SelectMenu]] options?: The "choices"/options of the component. - :ivar Optional[str] placeholder?: The placeholder text/value of the component. - :ivar Optional[int] min_values?: The minimum "options"/values to choose from the component. - :ivar Optional[int] max_values?: The maximum "options"/values to choose from the component. - :ivar Optional[List[Component]] components?: A list of components nested in the component. - :ivar Optional[int] min_length?: The minimum input length to choose from the component. - :ivar Optional[int] max_length?: The maximum input length to choose from the component. - :ivar Optional[bool] required?: Whether this component is required to be filled. - :ivar Optional[str] value?: The pre-filled value of the component. + :ivar Optional[str] custom_id: The customized "ID" of the component. + :ivar Optional[bool] disabled: Whether the component is unable to be used. + :ivar Optional[ButtonStyle] style: The style of the component. + :ivar Optional[str] label: The label of the component. + :ivar Optional[Emoji] emoji: The emoji used alongside the label of the component. + :ivar Optional[str] url: The URl route/path of the component. + :ivar Optional[List[SelectMenu]] options: The "choices"/options of the component. + :ivar Optional[str] placeholder: The placeholder text/value of the component. + :ivar Optional[int] min_values: The minimum "options"/values to choose from the component. + :ivar Optional[int] max_values: The maximum "options"/values to choose from the component. + :ivar Optional[List[Component]] components: A list of components nested in the component. + :ivar Optional[int] min_length: The minimum input length to choose from the component. + :ivar Optional[int] max_length: The maximum input length to choose from the component. + :ivar Optional[bool] required: Whether this component is required to be filled. + :ivar Optional[str] value: The pre-filled value of the component. """ type: ComponentType = field(converter=ComponentType) @@ -219,10 +219,10 @@ class TextInput(ComponentMixin): :ivar str custom_id: The custom Id of the input. :ivar str label: The label of the input. :ivar Optional[str] value: The pre-filled value of the input. - :ivar Optional[bool] required?: Whether the input is required or not. - :ivar Optional[str] placeholder?: The placeholder of the input. - :ivar Optional[int] min_length?: The minimum length of the input. - :ivar Optional[int] max_length?: The maximum length of the input. + :ivar Optional[bool] required: Whether the input is required or not. + :ivar Optional[str] placeholder: The placeholder of the input. + :ivar Optional[int] min_length: The minimum length of the input. + :ivar Optional[int] max_length: The maximum length of the input. """ type: ComponentType = field(converter=ComponentType, default=ComponentType.INPUT_TEXT) @@ -292,7 +292,7 @@ class ActionRow(ComponentMixin): interactions.ActionRow(components=[...]) :ivar int type: The type of component. Always defaults to ``1``. - :ivar Optional[List[Component]] components?: A list of components the ActionRow has, if any. + :ivar Optional[List[Component]] components: A list of components the ActionRow has, if any. """ type: ComponentType = field(ComponentType, default=ComponentType.ACTION_ROW) @@ -319,8 +319,7 @@ def new(cls, *components: Union[Button, SelectMenu, TextInput]) -> "ActionRow": r""" A class method for creating a new ``ActionRow``. - :param \*components: The components to add to the ``ActionRow``. - :type \*components: Union[Button, SelectMenu, TextInput] + :param Union[Button, SelectMenu, TextInput] \*components: The components to add to the ``ActionRow``. :return: A new ``ActionRow``. :rtype: ActionRow """ diff --git a/interactions/client/models/misc.py b/interactions/client/models/misc.py index 62f4aa9c8..2800120bd 100644 --- a/interactions/client/models/misc.py +++ b/interactions/client/models/misc.py @@ -50,13 +50,13 @@ class InteractionData(DictSerializerMixin): :ivar str id: The ID of the interaction data. :ivar str name: The name of the interaction. :ivar ApplicationCommandType type: The type of command from the interaction. - :ivar Optional[InteractionResolvedData] resolved?: The resolved version of the data. - :ivar Optional[Option, List[Option]] options?: The options of the interaction. - :ivar Optional[str] custom_id?: The custom ID of the interaction. - :ivar Optional[ComponentType] component_type?: The type of component from the interaction. - :ivar Optional[List[str]] values?: The values of the selected options in the interaction. - :ivar Optional[str] target_id?: The targeted ID of the interaction. - :ivar Optional[List[ActionRow]] components?: Array of Action Rows in modal. + :ivar Optional[InteractionResolvedData] resolved: The resolved version of the data. + :ivar Optional[Option, List[Option]] options: The options of the interaction. + :ivar Optional[str] custom_id: The custom ID of the interaction. + :ivar Optional[ComponentType] component_type: The type of component from the interaction. + :ivar Optional[List[str]] values: The values of the selected options in the interaction. + :ivar Optional[str] target_id: The targeted ID of the interaction. + :ivar Optional[List[ActionRow]] components: Array of Action Rows in modal. """ id: Snowflake = field(converter=Snowflake, default=None) @@ -81,14 +81,14 @@ class Interaction(DictSerializerMixin): :ivar str id: The ID of the interaction. :ivar str application_id: The application's ID of the interaction. :ivar InteractionType type: The type of interaction. - :ivar Optional[InteractionData] data?: The data of the interaction. - :ivar Optional[str] guild_id?: The guild ID of the interaction. - :ivar Optional[str] channel_id?: The channel ID of the interaction. - :ivar Optional[Member] member?: The member who invoked the interaction. - :ivar Optional[User] user?: The user who invoked the interaction. + :ivar Optional[InteractionData] data: The data of the interaction. + :ivar Optional[str] guild_id: The guild ID of the interaction. + :ivar Optional[str] channel_id: The channel ID of the interaction. + :ivar Optional[Member] member: The member who invoked the interaction. + :ivar Optional[User] user: The user who invoked the interaction. :ivar str token: The token of the interaction. - :ivar version: The version of the interaction as an autoincrement identifier. - :ivar Optional[Message] message?: The message of the interaction. + :ivar int version: The version of the interaction as an autoincrement identifier. + :ivar Optional[Message] message: The message of the interaction. """ id: Snowflake = field(converter=Snowflake) From f7d2b4b5d7d907d0fd7a1c5eff6f8d86d8bee440 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 18:56:46 +0100 Subject: [PATCH 08/32] update utils.py --- interactions/utils/utils.py | 64 +++++++++++++------------------------ 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/interactions/utils/utils.py b/interactions/utils/utils.py index 63d98fdb3..5c8cce18f 100644 --- a/interactions/utils/utils.py +++ b/interactions/utils/utils.py @@ -56,12 +56,9 @@ async def command(ctx): await asyncio.sleep(5) await ctx.send("I'm awake now!") - :param delay?: The amount of time in seconds to wait before defering the command. Defaults to ``2`` seconds. - :type delay?: Union[float, int] - :param ephemeral?: Whether the command is deferred ephemerally. Defaults to ``False``. - :type ephemeral?: bool - :param edit_origin?: Whether the command is deferred on origin. Defaults to ``False``. - :type edit_origin?: bool + :param Optional[Union[float, int]] delay: The amount of time in seconds to wait before defering the command. Defaults to ``2`` seconds. + :param Optional[bool] ephemeral?: Whether the command is deferred ephemerally. Defaults to ``False``. + :param Optional[bool] edit_origin?: Whether the command is deferred on origin. Defaults to ``False``. :return: The inner function, for decorating. :rtype: """ @@ -134,10 +131,10 @@ async def command(ctx): .. note:: You can only pass in :class:`.ActionRow`, :class:`.Button`, and :class:`.SelectMenu`, but in any order. - :param \*components: The components to spread. - :type \*components: Union[ActionRow, Button, SelectMenu] - :param max_in_row?: The maximum number of components in a single row. Defaults to ``5``. - :type max_in_row?: int + :param Union[ActionRow, Button, SelectMenu] \*components: The components to spread. + :param Optional[int] max_in_row: The maximum number of components in a single row. Defaults to ``5``. + :return: List of Action rows + :rtype: List[ActionRow] """ if not components or len(components) > 25: raise LibraryException(code=12, message="Number of components should be between 1 and 25.") @@ -179,17 +176,14 @@ async def command(ctx): def search_iterable( iterable: Iterable[_T], check: Optional[Callable[[_T], bool]] = None, /, **kwargs ) -> List[_T]: - """ + r""" Searches through an iterable for items that: - Are True for the check, if one is given - Have attributes that match the keyword arguments (e.x. passing `id=your_id` will only return objects with that id) - :param iterable: The iterable to search through - :type iterable: Iterable - :param check: The check that items will be checked against - :type check: Callable[[Any], bool] - :param kwargs: Any attributes the items should have - :type kwargs: Any + :param Iterable iterable: The iterable to search through + :param Callable[[Any], bool] check: The check that items will be checked against + :param Any \**kwargs: Any attributes the items should have :return: All items that match the check and keywords :rtype: list """ @@ -220,8 +214,7 @@ def disable_components( """ Disables the given components. - :param components: The components to disable - :type components: Union[List[Component], List[ActionRow], List[Button], List[SelectMenu], ActionRow, Component, Button, SelectMenu] + :param Union[List[Component], List[ActionRow], List[Button], List[SelectMenu], ActionRow, Component, Button, SelectMenu] components: The components to disable """ if isinstance(components, (Component, ActionRow)): for component in components.components: @@ -258,18 +251,12 @@ def get_channel_history( """ Gets the history of a channel. - :param http: The HTTPClient of the bot or your bot instance - :type http: Union[HTTPClient, Client] - :param channel: The channel to get the history from - :type channel: Union[int, str, Snowflake, Channel] - :param start_at?: The message to begin getting the history from - :type start_at?: Optional[Union[int, str, Snowflake, Message]] - :param reverse?: Whether to only get newer message. Default False - :type reverse?: Optional[bool] - :param check?: A check to ignore specific messages - :type check?: Optional[Callable[[Message], bool]] - :param maximum?: A set maximum of messages to get before stopping the iteration - :type maximum?: Optional[int] + :param Union[HTTPClient, Client] http: The HTTPClient of the bot or your bot instance + :param Union[int, str, Snowflake, Channel] channel: The channel to get the history from + :param Optional[Union[int, str, Snowflake, Message]] start_at: The message to begin getting the history from + :param Optional[bool] reverse: Whether to only get newer message. Default False + :param Optional[Callable[[Message], bool]] check: A check to ignore specific messages + :param Optional[int] maximum: A set maximum of messages to get before stopping the iteration :return: An asynchronous iterator over the history of the channel :rtype: AsyncHistoryIterator @@ -296,16 +283,11 @@ def get_guild_members( """ Gets the members of a guild - :param http: The HTTPClient of the bot or your bot instance - :type http: Union[HTTPClient, Client] - :param guild: The channel to get the history from - :type guild: Union[int, str, Snowflake, Guild] - :param start_at?: The message to begin getting the history from - :type start_at?: Optional[Union[int, str, Snowflake, Member]] - :param check?: A check to ignore specific messages - :type check?: Optional[Callable[[Member], bool]] - :param maximum?: A set maximum of members to get before stopping the iteration - :type maximum?: Optional[int] + :param Union[HTTPClient, Client] http: The HTTPClient of the bot or your bot instance + :param Union[int, str, Snowflake, Guild] guild: The channel to get the history from + :param Optional[Union[int, str, Snowflake, Member]] start_at: The message to begin getting the history from + :param Optional[Callable[[Member], bool]] check: A check to ignore specific messages + :param Optional[int] maximum: A set maximum of members to get before stopping the iteration :return: An asynchronous iterator over the history of the channel :rtype: AsyncMembersIterator From d554c81da34d02201e2b35eb3a2287aecdbbdcb2 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 19:21:20 +0100 Subject: [PATCH 09/32] update audit_log.py --- interactions/api/models/audit_log.py | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/interactions/api/models/audit_log.py b/interactions/api/models/audit_log.py index a94827d05..5c6706821 100644 --- a/interactions/api/models/audit_log.py +++ b/interactions/api/models/audit_log.py @@ -173,9 +173,9 @@ class AuditLogChange(DictSerializerMixin): """ A class object representing an AuditLogChange. - :ivar Optional[_T] new_value?: New value of the key - :ivar Optional[_T] old_value?: Old value of the key - :ivar str key: Name of the changed entity, with a few [exceptions](https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-exceptions) + :ivar Optional[_T] new_value: New value of the key + :ivar Optional[_T] old_value: Old value of the key + :ivar str key: Name of the changed entity, with a few `exceptions `_ """ new_value: Optional[_T] = field(default=None) @@ -188,17 +188,17 @@ class OptionalAuditEntryInfo(DictSerializerMixin): """ A class object representing OptionalAuditEntryInfo. - :ivar Snowflake application_id: ID of the app whose permissions were targeted. ``AuditLogEvents``-type: 121 - :ivar Snowflake channel_id: Channel in which the entities were targeted. ``AuditLogEvents``-types: 26, 74, 75, 72, 83, 84, 85 - :ivar str auto_moderation_rule_name: Name of the Auto Moderation rule that was triggered. ``AuditLogEvents``-types: 143, 144, 145 - :ivar str auto_moderation_rule_trigger_type: Trigger type of the Auto Moderation rule that was triggered. ``AuditLogEvents``-types: 143, 144, 145 - :ivar str count: Number of entities that were targeted. ``AuditLogEvents``-types: 72, 73, 27, 26 - :ivar str delete_member_days: Number of days after which inactive members were kicked. ``AuditLogEvents``-types: 21 - :ivar Snowflake id: ID of the overwritten entity. ``AuditLogEvents``-types: 13, 14, 15 - :ivar str members_removed: Number of members removed by the prune. ``AuditLogEvents``-types: 21 - :ivar Snowflake message_id: ID of the message that was targeted. ``AuditLogEvents``-types: 74, 75 - :ivar Optional[str] role_name: Name of the role if type is "0" (not present if type is "1"). ``AuditLogEvents``-types: 13, 14, 15 - :ivar str type: Type of overwritten entity - role ("0") or member ("1"). ``AuditLogEvents``-types: 13, 14, 15 + :ivar Snowflake application_id: ID of the app whose permissions were targeted. Used in event :attr:`AuditLogEvents.APPLICATION_COMMAND_PERMISSION_UPDATE`. + :ivar str auto_moderation_rule_name: Name of the Auto Moderation rule that was triggered. Used in events :attr:`AuditLogEvents.AUTO_MODERATION_BLOCK_MESSAGE`, :attr:`AuditLogEvents.AUTO_MODERATION_FLAG_TO_CHANNEL` & :attr:`AuditLogEvents.AUTO_MODERATION_USER_COMMUNICATION_DISABLED`. + :ivar str auto_moderation_rule_trigger_type: Trigger type of the Auto Moderation rule that was triggered. Used in events :attr:`AuditLogEvents.AUTO_MODERATION_BLOCK_MESSAGE`, :attr:`AuditLogEvents.AUTO_MODERATION_FLAG_TO_CHANNEL` & :attr:`AuditLogEvents.AUTO_MODERATION_USER_COMMUNICATION_DISABLED`. + :ivar Snowflake channel_id: Channel in which the entities were targeted. Used in events :attr:`AuditLogEvents.MEMBER_MOVE`, :attr:`AuditLogEvents.MESSAGE_PIN`, :attr:`AuditLogEvents.MESSAGE_UNPIN`, :attr:`AuditLogEvents.MESSAGE_DELETE`, :attr:`AuditLogEvents.STAGE_INSTANCE_CREATE`, :attr:`AuditLogEvents.STAGE_INSTANCE_UPDATE`, :attr:`AuditLogEvents.STAGE_INSTANCE_DELETE`, :attr:`AuditLogEvents.AUTO_MODERATION_BLOCK_MESSAGE`, :attr:`AuditLogEvents.AUTO_MODERATION_FLAG_TO_CHANNEL` & :attr:`AuditLogEvents.AUTO_MODERATION_USER_COMMUNICATION_DISABLED`. + :ivar str count: Number of entities that were targeted. Used in events :attr:`AuditLogEvents.MESSAGE_DELETE`, :attr:`AuditLogEvents.MESSAGE_BULK_DELETE`, :attr:`AuditLogEvents.MEMBER_DISCONNECT` & :attr:`AuditLogEvents.MEMBER_MOVE` + :ivar str delete_member_days: Number of days after which inactive members were kicked. Used in event :attr:`AuditLogEvents.MEMBER_PRUNE` + :ivar Snowflake id: ID of the overwritten entity. Used in events :attr:`AuditLogEvents.CHANNEL_OVERWRITE_CREATE`, :attr:`AuditLogEvents.CHANNEL_OVERWRITE_UPDATE` & :attr:`AuditLogEvents.CHANNEL_OVERWRITE_DELETE` + :ivar str members_removed: Number of members removed by the prune. Used in event :attr:`AuditLogEvents.MEMBER_PRUNE` + :ivar Snowflake message_id: ID of the message that was targeted. Used in events :attr:`AuditLogEvents.MESSAGE_PIN` & :attr:`AuditLogEvents.MESSAGE_UNPIN` + :ivar Optional[str] role_name: Name of the role if type is "0" (not present if type is "1"). Used in events :attr:`AuditLogEvents.CHANNEL_OVERWRITE_CREATE`, :attr:`AuditLogEvents.CHANNEL_OVERWRITE_UPDATE` & :attr:`AuditLogEvents.CHANNEL_OVERWRITE_DELETE` + :ivar str type: Type of overwritten entity - role ("0") or member ("1"). Used in events :attr:`AuditLogEvents.CHANNEL_OVERWRITE_CREATE`, :attr:`AuditLogEvents.CHANNEL_OVERWRITE_UPDATE` & :attr:`AuditLogEvents.CHANNEL_OVERWRITE_DELETE` """ application_id: Snowflake = field(converter=Snowflake) @@ -219,13 +219,13 @@ class AuditLogEntry(DictSerializerMixin): """ A class object representing an AuditLogEntry. - :ivar Optional[str] target_id?: ID of the affected entity (webhook, user, role, etc.) - :ivar Optional[List[AuditLogChange]] changes?: Changes made to the target_id - :ivar Optional[Snowflake] user_id?: User or app that made the changes + :ivar Optional[str] target_id: ID of the affected entity (webhook, user, role, etc.) + :ivar Optional[List[AuditLogChange]] changes: Changes made to the target_id + :ivar Optional[Snowflake] user_id: User or app that made the changes :ivar Snowflake id: ID of the entry :ivar AuditLogEvents action_type: Type of action that occurred - :ivar OptionalAuditEntryInfo options?: Additional info for certain event types - :ivar str reason?: Reason for the change (1-512 characters) + :ivar OptionalAuditEntryInfo options: Additional info for certain event types + :ivar str reason: Reason for the change (1-512 characters) """ target_id: Optional[str] = field(default=None) From 1f8d7c2849fb3ecd932ea672e9bc08c6a4cf3851 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 23:03:49 +0100 Subject: [PATCH 10/32] update channel.py --- interactions/api/models/channel.py | 378 +++++++++++------------------ 1 file changed, 136 insertions(+), 242 deletions(-) diff --git a/interactions/api/models/channel.py b/interactions/api/models/channel.py index a84420b3f..34a301125 100644 --- a/interactions/api/models/channel.py +++ b/interactions/api/models/channel.py @@ -73,7 +73,7 @@ class ThreadMetadata(DictSerializerMixin): :ivar int auto_archive_duration: The auto-archive time. :ivar datetime archive_timestamp: The timestamp that the thread will be/has been closed at. :ivar bool locked: The current message state of the thread. - :ivar Optional[bool] invitable?: The ability to invite users to the thread. + :ivar Optional[bool] invitable: The ability to invite users to the thread. """ archived: bool = field() @@ -92,7 +92,7 @@ class ThreadMember(ClientSerializerMixin): ``id`` only shows if there are active intents involved with the member in the thread. - :ivar Optional[Snowflake] id?: The "ID" or intents of the member. + :ivar Optional[Snowflake] id: The "ID" or intents of the member. :ivar Snowflake user_id: The user ID of the member. :ivar datetime join_timestamp: The timestamp of when the member joined the thread. :ivar int flags: The bitshift flags for the member in the thread. @@ -113,18 +113,12 @@ class AsyncHistoryIterator(DiscordPaginationIterator): """ A class object that allows iterating through a channel's history. - :param _client: The HTTPClient of the bot - :type _client: HTTPClient - :param obj: The channel to get the history from - :type obj: Union[int, str, Snowflake, Channel] - :param start_at?: The message to begin getting the history from - :type start_at?: Optional[Union[int, str, Snowflake, Message]] - :param reverse?: Whether to only get newer message. Default False - :type reverse?: Optional[bool] - :param check?: A check to ignore certain messages - :type check?: Optional[Callable[[Member], bool]] - :param maximum?: A set maximum of messages to get before stopping the iteration - :type maximum?: Optional[int] + :param HTTPClient _client: The HTTPClient of the bot + :param Union[int, str, Snowflake, Channel] obj: The channel to get the history from + :param Optional[Union[int, str, Snowflake, Message]] start_at: The message to begin getting the history from + :param Optional[bool] reverse: Whether to only get newer message. Default False + :param Optional[Callable[[Member], bool]] check: A check to ignore certain messages + :param Optional[int] maximum: A set maximum of messages to get before stopping the iteration """ def __init__( @@ -184,7 +178,7 @@ async def get_first_objects(self) -> None: self.objects = [Message(**msg, _client=self._client) for msg in msgs] async def flatten(self) -> List["Message"]: - """returns all remaining items as list""" + """Returns all remaining items as list""" return [item async for item in self] async def get_objects(self) -> None: @@ -248,10 +242,8 @@ class AsyncTypingContextManager(BaseAsyncContextManager): """ An async context manager for triggering typing. - :param obj: The channel to trigger typing in. - :type obj: Union[int, str, Snowflake, Channel] - :param _client: The HTTPClient of the bot - :type _client: HTTPClient + :param Union[int, str, Snowflake, Channel] obj: The channel to trigger typing in. + :param HTTPClient _client: The HTTPClient of the bot """ def __init__( @@ -294,8 +286,8 @@ class Tags(ClientSerializerMixin): # helpers, hehe :D :ivar str name: Name of the tag. The limit is up to 20 characters. :ivar int id: ID of the tag. Can also be 0 if manually created. - :ivar bool moderated: A boolean denoting whether this tag can be removed/added by moderators with ``manage_threads`` permissions. - :ivar Optional[Emoji] emoji?: The emoji to represent the tag, if any. + :ivar bool moderated: A boolean denoting whether this tag can be removed/added by moderators with the :attr:`.Permissions.MANAGE_THREADS` permission. + :ivar Optional[Emoji] emoji: The emoji to represent the tag, if any. """ @@ -313,8 +305,7 @@ async def delete( """ Deletes this tag - :param channel_id: The ID of the channel where the tag belongs to - :type channel_id: Union[int, str, Snowflake, Channel] + :param Union[int, str, Snowflake, Channel] channel_id: The ID of the channel where the tag belongs to """ if isinstance(channel_id, Channel) and channel_id.type != ChannelType.GUILD_FORUM: raise LibraryException(code=14, message="Can only manage tags on a forum channel") @@ -340,14 +331,10 @@ async def edit( Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis. - :param channel_id: The ID of the channel where the tag belongs to - :type channel_id: Union[int, str, Snowflake, Channel] - :param name: The new name of the tag - :type name: str - :param emoji_id: The ID of the emoji to use for the tag - :type emoji_id: Optional[int] - :param emoji_name: The name of the emoji to use for the tag - :type emoji_name: Optional[int] + :param Union[int, str, Snowflake, Channel] channel_id: The ID of the channel where the tag belongs to + :param str name: The new name of the tag + :param Optional[int] emoji_id: The ID of the emoji to use for the tag + :param Optional[int] emoji_name: The name of the emoji to use for the tag :return: The modified tag :rtype: Tags """ @@ -382,40 +369,36 @@ class Channel(ClientSerializerMixin, IDMixin): """ A class object representing all types of channels. - .. note:: - The purpose of this model is to be used as a base class, and - is never needed to be used directly. - :ivar Snowflake id: The (snowflake) ID of the channel. :ivar ChannelType type: The type of channel. - :ivar Optional[Snowflake] guild_id?: The ID of the guild if it is not a DM channel. - :ivar Optional[int] position?: The position of the channel. + :ivar Optional[Snowflake] guild_id: The ID of the guild if it is not a DM channel. + :ivar Optional[int] position: The position of the channel. :ivar List[Overwrite] permission_overwrites: The non-synced permissions of the channel. :ivar str name: The name of the channel. - :ivar Optional[str] topic?: The description of the channel. - :ivar Optional[bool] nsfw?: Whether the channel is NSFW. + :ivar Optional[str] topic: The description of the channel. + :ivar Optional[bool] nsfw: Whether the channel is NSFW. :ivar Snowflake last_message_id: The ID of the last message sent. - :ivar Optional[int] bitrate?: The audio bitrate of the channel. - :ivar Optional[int] user_limit?: The maximum amount of users allowed in the channel. - :ivar Optional[int] rate_limit_per_user?: The concurrent ratelimit for users in the channel. - :ivar Optional[List[User]] recipients?: The recipients of the channel. - :ivar Optional[str] icon?: The icon of the channel. - :ivar Optional[Snowflake] owner_id?: The owner of the channel. - :ivar Optional[Snowflake] application_id?: The application of the channel. - :ivar Optional[Snowflake] parent_id?: The ID of the "parent"/main channel. - :ivar Optional[datetime] last_pin_timestamp?: The timestamp of the last pinned message in the channel. - :ivar Optional[str] rtc_region?: The region of the WebRTC connection for the channel. - :ivar Optional[int] video_quality_mode?: The set quality mode for video streaming in the channel. + :ivar Optional[int] bitrate: The audio bitrate of the channel. + :ivar Optional[int] user_limit: The maximum amount of users allowed in the channel. + :ivar Optional[int] rate_limit_per_user: The concurrent ratelimit for users in the channel. + :ivar Optional[List[User]] recipients: The recipients of the channel. + :ivar Optional[str] icon: The icon of the channel. + :ivar Optional[Snowflake] owner_id: The owner of the channel. + :ivar Optional[Snowflake] application_id: The application of the channel. + :ivar Optional[Snowflake] parent_id: The ID of the "parent"/main channel. + :ivar Optional[datetime] last_pin_timestamp: The timestamp of the last pinned message in the channel. + :ivar Optional[str] rtc_region: The region of the WebRTC connection for the channel. + :ivar Optional[int] video_quality_mode: The set quality mode for video streaming in the channel. :ivar int message_count: The amount of messages in the channel. - :ivar Optional[int] member_count?: The amount of members in the channel. - :ivar Optional[bool] newly_created?: Boolean representing if a thread is created. - :ivar Optional[ThreadMetadata] thread_metadata?: The thread metadata of the channel. - :ivar Optional[ThreadMember] member?: The member of the thread in the channel. - :ivar Optional[int] default_auto_archive_duration?: The set auto-archive time for all threads to naturally follow in the channel. - :ivar Optional[str] permissions?: The permissions of the channel. - :ivar Optional[int] flags?: The flags of the channel. - :ivar Optional[int] total_message_sent?: Number of messages ever sent in a thread. - :ivar Optional[int] default_thread_slowmode_delay?: The default slowmode delay in seconds for threads, if this channel is a forum. + :ivar Optional[int] member_count: The amount of members in the channel. + :ivar Optional[bool] newly_created: Boolean representing if a thread is created. + :ivar Optional[ThreadMetadata] thread_metadata: The thread metadata of the channel. + :ivar Optional[ThreadMember] member: The member of the thread in the channel. + :ivar Optional[int] default_auto_archive_duration: The set auto-archive time for all threads to naturally follow in the channel. + :ivar Optional[str] permissions: The permissions of the channel. + :ivar Optional[int] flags: The flags of the channel. + :ivar Optional[int] total_message_sent: Number of messages ever sent in a thread. + :ivar Optional[int] default_thread_slowmode_delay: The default slowmode delay in seconds for threads, if this channel is a forum. :ivar Optional[List[Tags]] available_tags: Tags in a forum channel, if any. :ivar Optional[Emoji] default_reaction_emoji: Default reaction emoji for threads created in a forum, if any. """ @@ -506,14 +489,10 @@ def history( check: Optional[Callable[["Message"], bool]] = None, ) -> AsyncHistoryIterator: """ - :param start_at?: The message to begin getting the history from - :type start_at?: Optional[Union[int, str, Snowflake, Message]] - :param reverse?: Whether to only get newer message. Default False - :type reverse?: Optional[bool] - :param maximum?: A set maximum of messages to get before stopping the iteration - :type maximum?: Optional[int] - :param check?: A custom check to ignore certain messages - :type check?: Optional[Callable[[Message], bool]] + :param Optional[Union[int, str, Snowflake, Message]] start_at: The message to begin getting the history from + :param Optional[bool] reverse: Whether to only get newer message. Default False + :param Optional[int] maximum: A set maximum of messages to get before stopping the iteration + :param Optional[Callable[[Message], bool]] check: A custom check to ignore certain messages :return: An asynchronous iterator over the history of the channel :rtype: AsyncHistoryIterator @@ -549,22 +528,14 @@ async def send( """ Sends a message in the channel. - :param content?: The contents of the message as a string or string-converted value. - :type content?: Optional[str] - :param tts?: Whether the message utilizes the text-to-speech Discord programme or not. - :type tts?: Optional[bool] - :param files?: A file or list of files to be attached to the message. - :type files?: Optional[Union[File, List[File]]] - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param embeds?: An embed, or list of embeds for the message. - :type embeds?: Optional[Union[Embed, List[Embed]]] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] - :param stickers?: A list of stickers to send with your message. You can send up to 3 stickers per message. - :type stickers?: Optional[List[Sticker]] - :param components?: A component, or list of components for the message. - :type components?: Optional[Union[ActionRow, Button, SelectMenu, List[Actionrow], List[Button], List[SelectMenu]]] + :param Optional[str] content: The contents of the message as a string or string-converted value. + :param Optional[bool] tts: Whether the message utilizes the text-to-speech Discord programme or not. + :param Optional[Union[File, List[File]]] files: A file or list of files to be attached to the message. + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Optional[Union[Embed, List[Embed]]] embeds: An embed, or list of embeds for the message. + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. + :param Optional[List[Sticker]] stickers: A list of stickers to send with your message. You can send up to 3 stickers per message. + :param Optional[Union[ActionRow, Button, SelectMenu, List[Actionrow], List[Button], List[SelectMenu]]] components: A component, or list of components for the message. :return: The sent message as an object. :rtype: Message """ @@ -661,34 +632,21 @@ async def modify( Edits the channel. .. note:: - The fields `archived`, `auto_archive_duration` and `locked` require the provided channel to be a thread. - - :param name?: The name of the channel, defaults to the current value of the channel - :type name?: str - :param topic?: The topic of that channel, defaults to the current value of the channel - :type topic?: Optional[str] - :param bitrate?: (voice channel only) The bitrate (in bits) of the voice channel, defaults to the current value of the channel - :type bitrate?: Optional[int] - :param user_limit?: (voice channel only) Maximum amount of users in the channel, defaults to the current value of the channel - :type user_limit?: Optional[int] - :param rate_limit_per_use?: Amount of seconds a user has to wait before sending another message (0-21600), defaults to the current value of the channel - :type rate_limit_per_user: Optional[int] - :param position?: Sorting position of the channel, defaults to the current value of the channel - :type position?: Optional[int] - :param parent_id?: The id of the parent category for a channel, defaults to the current value of the channel - :type parent_id?: Optional[int] - :param nsfw?: Whether the channel is nsfw or not, defaults to the current value of the channel - :type nsfw?: Optional[bool] - :param permission_overwrites?: The permission overwrites, if any - :type permission_overwrites?: Optional[List[Overwrite]] - :param archived?: Whether the thread is archived - :type archived?: Optional[bool] - :param auto_archive_duration?: The time after the thread is automatically archived. One of 60, 1440, 4320, 10080 - :type auto_archive_duration?: Optional[int] - :param locked?: Whether the thread is locked - :type locked?: Optional[bool] - :param reason?: The reason for the edit - :type reason?: Optional[str] + The fields ``archived``, ``auto_archive_duration`` and ``locked`` require the provided channel to be a thread. + + :param Optional[str] name: The name of the channel, defaults to the current value of the channel + :param Optional[str] topic: The topic of that channel, defaults to the current value of the channel + :param Optional[int] bitrate: (voice channel only) The bitrate (in bits) of the voice channel, defaults to the current value of the channel + :param Optional[int] user_limit: (voice channel only) Maximum amount of users in the channel, defaults to the current value of the channel + :param Optional[int] rate_limit_per_use: Amount of seconds a user has to wait before sending another message (0-21600), defaults to the current value of the channel + :param Optional[int] position: Sorting position of the channel, defaults to the current value of the channel + :param Optional[int] parent_id: The id of the parent category for a channel, defaults to the current value of the channel + :param Optional[bool] nsfw: Whether the channel is nsfw or not, defaults to the current value of the channel + :param Optional[List[Overwrite]] permission_overwrites: The permission overwrites, if any + :param Optional[bool] archived: Whether the thread is archived + :param Optional[int] auto_archive_duration: The time after the thread is automatically archived. One of 60, 1440, 4320, 10080 + :param Optional[bool] locked: Whether the thread is locked + :param Optional[str] reason: The reason for the edit :return: The modified channel as new object :rtype: Channel """ @@ -761,10 +719,8 @@ async def set_name( """ Sets the name of the channel. - :param name: The new name of the channel - :type name: str - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param str name: The new name of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -780,10 +736,8 @@ async def set_topic( """ Sets the topic of the channel. - :param topic: The new topic of the channel - :type topic: str - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param str topic: The new topic of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -799,10 +753,8 @@ async def set_bitrate( """ Sets the bitrate of the channel. - :param bitrate: The new bitrate of the channel - :type bitrate: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int bitrate: The new bitrate of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -821,10 +773,8 @@ async def set_user_limit( """ Sets the user_limit of the channel. - :param user_limit: The new user limit of the channel - :type user_limit: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int user_limit: The new user limit of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -845,10 +795,8 @@ async def set_rate_limit_per_user( """ Sets the amount of seconds a user has to wait before sending another message. - :param rate_limit_per_user: The new rate_limit_per_user of the channel (0-21600) - :type rate_limit_per_user: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int rate_limit_per_user: The new rate_limit_per_user of the channel (0-21600) + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -864,10 +812,8 @@ async def set_position( """ Sets the position of the channel. - :param position: The new position of the channel - :type position: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int position: The new position of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -883,10 +829,8 @@ async def set_parent_id( """ Sets the parent_id of the channel. - :param parent_id: The new parent_id of the channel - :type parent_id: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int parent_id: The new parent_id of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -902,10 +846,8 @@ async def set_nsfw( """ Sets the nsfw-flag of the channel. - :param nsfw: The new nsfw-flag of the channel - :type nsfw: bool - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param bool nsfw: The new nsfw-flag of the channel + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -921,10 +863,8 @@ async def archive( """ Sets the archived state of the thread. - :param archived: Whether the Thread is archived, defaults to True - :type archived: bool - :param reason?: The reason of the archiving - :type reason?: Optional[str] + :param bool archived: Whether the Thread is archived, defaults to True + :param Optional[str] reason: The reason of the archiving :return: The edited channel :rtype: Channel """ @@ -940,10 +880,8 @@ async def set_auto_archive_duration( """ Sets the time after the thread is automatically archived. - :param auto_archive_duration: The time after the thread is automatically archived. One of 60, 1440, 4320, 10080 - :type auto_archive_duration: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int auto_archive_duration: The time after the thread is automatically archived. One of 60, 1440, 4320, 10080 + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -959,10 +897,8 @@ async def lock( """ Sets the locked state of the thread. - :param locked: Whether the Thread is locked, defaults to True - :type locked: bool - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param bool locked: Whether the Thread is locked, defaults to True + :param Optional[str] reason: The reason of the edit :return: The edited channel :rtype: Channel """ @@ -976,8 +912,7 @@ async def add_member( """ This adds a member to the channel, if the channel is a thread. - :param member_id: The id of the member to add to the channel - :type member_id: int + :param int member_id: The id of the member to add to the channel """ if not self._client: raise LibraryException(code=13) @@ -997,8 +932,7 @@ async def remove_member( """ This removes a member of the channel, if the channel is a thread. - :param member_id: The id of the member to remove of the channel - :type member_id: int + :param int member_id: The id of the member to remove of the channel """ if not self._client: raise LibraryException(code=13) @@ -1018,8 +952,7 @@ async def pin_message( """ Pins a message to the channel. - :param message_id: The id of the message to pin - :type message_id: Union[int, Snowflake, "Message"] + :param Union[int, Snowflake, Message] message_id: The id of the message to pin """ if not self._client: raise LibraryException(code=13) @@ -1037,8 +970,7 @@ async def unpin_message( """ Unpins a message from the channel. - :param message_id: The id of the message to unpin - :type message_id: Union[int, Snowflake, "Message"] + :param Union[int, Snowflake, Message] message_id: The id of the message to unpin """ if not self._client: raise LibraryException(code=13) @@ -1055,8 +987,7 @@ async def publish_message( ) -> "Message": """Publishes (API calls it crossposts) a message in the channel to any that is followed by. - :param message_id: The id of the message to publish - :type message_id: Union[int, Snowflake, "Message"] + :param Union[int, Snowflake, Message] message_id: The id of the message to publish :return: The message published :rtype: Message """ @@ -1093,8 +1024,7 @@ async def get_message( """ Gets a message sent in that channel. - :param message_id: The ID of the message to get - :type message_id: Union[int, Snowflake] + :param Union[int, Snowflake] message_id: The ID of the message to get :return: The message as object :rtype: Message """ @@ -1125,16 +1055,11 @@ def check_pinned(message): return not message.pinned # This returns `True` only if the message is the message is not pinned await channel.purge(100, check=check_pinned) # This will delete the newest 100 messages that are not pinned in that channel - :param amount: The amount of messages to delete - :type amount: int - :param check?: The function used to check if a message should be deleted. The message is only deleted if the check returns `True` - :type check?: Callable[[Message], bool] - :param before?: An id of a message to purge only messages before that message - :type before?: Optional[int] - :param bulk?: Whether to bulk delete the messages (you cannot delete messages older than 14 days, default) or to delete every message seperately - :param bulk: Optional[bool] - :param reason?: The reason of the deletes - :type reason?: Optional[str] + :param int amount: The amount of messages to delete + :param Callable[[Message], bool] check: The function used to check if a message should be deleted. The message is only deleted if the check returns `True` + :param Optional[int] before: An id of a message to purge only messages before that message + :param Optional[bool] bulk: Whether to bulk delete the messages (you cannot delete messages older than 14 days, default) or to delete every message seperately + :param Optional[str] reason: The reason of the deletes :return: A list of the deleted messages :rtype: List[Message] """ @@ -1320,19 +1245,12 @@ async def create_thread( """ Creates a thread in the Channel. - :param name: The name of the thread - :type name: str - :param auto_archive_duration?: duration in minutes to automatically archive the thread after recent activity, - can be set to: 60, 1440, 4320, 10080 - :type auto_archive_duration?: Optional[int] - :param type?: The type of thread, defaults to public. ignored if creating thread from a message - :type type?: Optional[ChannelType] - :param invitable?: Boolean to display if the Thread is open to join or private. - :type invitable?: Optional[bool] - :param message_id?: An optional message to create a thread from. - :type message_id?: Optional[Union[int, Snowflake, "Message"]] - :param reason?: An optional reason for the audit log - :type reason?: Optional[str] + :param str name: The name of the thread + :param Optional[int] auto_archive_duration: duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 + :param Optional[ChannelType] type: The type of thread, defaults to public. ignored if creating thread from a message + :param Optional[bool] invitable: Boolean to display if the Thread is open to join or private. + :param Optional[Union[int, Snowflake, Message]] message_id: An optional message to create a thread from. + :param Optional[str] reason: An optional reason for the audit log :return: The created thread :rtype: Channel """ @@ -1368,6 +1286,8 @@ async def create_thread( @property def url(self) -> str: + """ + Returns the URL of the channel""" _guild_id = self.guild_id if isinstance(self.guild_id, int) else "@me" return f"https://discord.com/channels/{_guild_id}/{self.id}" @@ -1385,22 +1305,14 @@ async def create_invite( """ Creates an invite for the channel - :param max_age?: Duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days). Default 86400 (24h) - :type max_age?: Optional[int] - :param max_uses?: Max number of uses or 0 for unlimited. between 0 and 100. Default 0 - :type max_uses?: Optional[int] - :param temporary?: Whether this invite only grants temporary membership. Default False - :type temporary?: Optional[bool] - :param unique?: If true, don't try to reuse a similar invite (useful for creating many unique one time use invites). Default False - :type unique?: Optional[bool] - :param target_type?: The type of target for this voice channel invite - :type target_type?: Optional["InviteTargetType"] - :param target_user_id?: The id of the user whose stream to display for this invite, required if target_type is STREAM, the user must be streaming in the channel - :type target_user_id?: Optional[int] - :param target_application_id?: The id of the embedded application to open for this invite, required if target_type is EMBEDDED_APPLICATION, the application must have the EMBEDDED flag - :type target_application_id?: Optional[int] - :param reason?: The reason for the creation of the invite - :type reason?: Optional[str] + :param Optional[int] max_age: Duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days). Default 86400 (24h) + :param Optional[int] max_uses: Max number of uses or 0 for unlimited. between 0 and 100. Default 0 + :param Optional[bool] temporary: Whether this invite only grants temporary membership. Default False + :param Optional[bool] unique: If true, don't try to reuse a similar invite (useful for creating many unique one time use invites). Default False + :param Optional[InviteTargetType] target_type: The type of target for this voice channel invite + :param Optional[int] target_user_id: The id of the user whose stream to display for this invite, required if target_type is STREAM, the user must be streaming in the channel + :param Optional[int] target_application_id: The id of the embedded application to open for this invite, required if target_type is EMBEDDED_APPLICATION, the application must have the EMBEDDED flag + :param Optional[str] reason: The reason for the creation of the invite """ if not self._client: @@ -1455,8 +1367,7 @@ async def get_history(self, limit: int = 100) -> Optional[List["Message"]]: """ Gets messages from the channel's history. - :param limit?: The amount of messages to get. Default 100 - :type limit?: int + :param int limit: The amount of messages to get. Default 100 :return: A list of messages :rtype: List[Message] """ @@ -1570,12 +1481,9 @@ async def create_tag( Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis. - :param name: The name of the tag - :type name: str - :param emoji_id: The ID of the emoji to use for the tag - :type emoji_id: Optional[int] - :param emoji_name: The name of the emoji to use for the tag - :type emoji_name: Optional[str] + :param str name: The name of the tag + :param Optional[int] emoji_id: The ID of the emoji to use for the tag + :param Optional[str] emoji_name: The name of the emoji to use for the tag :return: The create tag object :rtype: Tags """ @@ -1616,14 +1524,10 @@ async def edit_tag( Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis. - :param tag_id: The ID of the tag to edit - :type tag_id: Union[int, str, Snowflake, Tag] - :param name: The new name of the tag - :type name: str - :param emoji_id: The ID of the emoji to use for the tag - :type emoji_id: Optional[int] - :param emoji_name: The name of the emoji to use for the tag - :type emoji_name: Optional[int] + :param Union[int, str, Snowflake, Tags] tag_id: The ID of the tag to edit + :param str name: The new name of the tag + :param Optional[int] emoji_id: The ID of the emoji to use for the tag + :param Optional[int] emoji_name: The name of the emoji to use for the tag :return: The modified tag :rtype: Tags """ @@ -1654,8 +1558,7 @@ async def delete_tag( """ Deletes a tag - :param tag_id: The ID of the Tag - :type tag_id: Union[int, str, Snowflake, Tags] + :param Union[int, str, Snowflake, Tags] tag_id: The ID of the Tag """ if self.type != ChannelType.GUILD_FORUM: raise LibraryException(code=14, message="Tags can only be created in forum channels!") @@ -1679,22 +1582,14 @@ async def create_forum_post( """ Creates a new post inside a forum channel - :param name: The name of the thread - :type name: str - :param auto_archive_duration: duration in minutes to automatically archive the thread after recent activity, - can be set to: 60, 1440, 4320, 10080 - :type auto_archive_duration: Optional[int] - :param content: The content to send as first message. - :type content: Union[dict, "Message", str, "Attachment", List["Attachment"]] - :param applied_tags: Tags to give to the created thread - :type applied_tags: Union[List[str], List[int], List[Tags], int, str, Tags] - :param files: An optional list of files to send attached to the message. - :type files: Optional[List[File]] - :param rate_limit_per_user: Seconds a user has to wait before sending another message (0 to 21600), if given. - :type rate_limit_per_user: Optional[int] - :param reason: An optional reason for the audit log - :type reason: Optional[str] - :returns: A channel of ChannelType 11 (THREAD) + :param str name: The name of the thread + :param Optional[int] auto_archive_duration: duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 + :param Union[dict, Message, str, Attachment, List[Attachment]] content: The content to send as first message. + :param Union[List[str], List[int], List[Tags], int, str, Tags] applied_tags: Tags to give to the created thread + :param Optional[List[File]] files: An optional list of files to send attached to the message. + :param Optional[int] rate_limit_per_user: Seconds a user has to wait before sending another message (0 to 21600), if given. + :param Optional[str] reason: An optional reason for the audit log + :returns: A channel of type :attr:`ChannelType.PUBLIC_THREAD` :rtype: Channel """ @@ -1826,8 +1721,7 @@ async def get_permissions_for(self, member: "Member") -> Permissions: user overwrites that can be assigned to channels or categories. If you don't need these overwrites, look into :meth:`.Member.get_guild_permissions`. - :param member: The member to get the permissions from - :type member: Member + :param Member member: The member to get the permissions from :return: Permissions of the member in this channel :rtype: Permissions """ From 3d50874f39b75302598776fcbb5a008f0d13e50d Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 23:03:54 +0100 Subject: [PATCH 11/32] update emoji.py --- interactions/api/models/emoji.py | 37 +++++++++++++------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/interactions/api/models/emoji.py b/interactions/api/models/emoji.py index 317a80b19..6329d873d 100644 --- a/interactions/api/models/emoji.py +++ b/interactions/api/models/emoji.py @@ -17,14 +17,14 @@ class Emoji(ClientSerializerMixin): """ A class objecting representing an emoji. - :ivar Optional[Snowflake] id?: Emoji id - :ivar Optional[str] name?: Emoji name. - :ivar Optional[List[int]] roles?: Roles allowed to use this emoji - :ivar Optional[User] user?: User that created this emoji - :ivar Optional[bool] require_colons?: Status denoting of this emoji must be wrapped in colons - :ivar Optional[bool] managed?: Status denoting if this emoji is managed (by an integration) - :ivar Optional[bool] animated?: Status denoting if this emoji is animated - :ivar Optional[bool] available?: Status denoting if this emoji can be used. (Can be false via server boosting) + :ivar Optional[Snowflake] id: Emoji id + :ivar Optional[str] name: Emoji name. + :ivar Optional[List[int]] roles: Roles allowed to use this emoji + :ivar Optional[User] user: User that created this emoji + :ivar Optional[bool] require_colons: Status denoting of this emoji must be wrapped in colons + :ivar Optional[bool] managed: Status denoting if this emoji is managed (by an integration) + :ivar Optional[bool] animated: Status denoting if this emoji is animated + :ivar Optional[bool] available: Status denoting if this emoji can be used. (Can be false via server boosting) """ id: Optional[Snowflake] = field(converter=Snowflake, default=None) @@ -53,12 +53,9 @@ async def get( """ Gets an emoji. - :param guild_id: The id of the guild of the emoji - :type guild_id: Union[int, Snowflake, "Guild"] - :param emoji_id: The id of the emoji - :type emoji_id: Union[int, Snowflake] - :param client: The HTTPClient of your bot. Equals to ``bot._http`` - :type client: HTTPClient + :param Union[int, Snowflake, Guild] guild_id: The id of the guild of the emoji + :param Union[int, Snowflake] emoji_id: The id of the emoji + :param HTTPClient client: The HTTPClient of your bot. Equals to ``bot._http`` :return: The Emoji as object :rtype: Emoji """ @@ -77,10 +74,8 @@ async def get_all_of_guild( """ Gets all emoji of a guild. - :param guild_id: The id of the guild to get the emojis of - :type guild_id: Union[int, Snowflake, "Guild"] - :param client: The HTTPClient of your bot. Equals to ``bot._http`` - :type client: HTTPClient + :param Union[int, Snowflake, Guild] guild_id: The id of the guild to get the emojis of + :param HTTPClient client: The HTTPClient of your bot. Equals to ``bot._http`` :return: The Emoji as list :rtype: List[Emoji] """ @@ -98,10 +93,8 @@ async def delete( """ Deletes the emoji. - :param guild_id: The guild id to delete the emoji from - :type guild_id: Union[int, Snowflake, "Guild"] - :param reason?: The reason of the deletion - :type reason?: Optional[str] + :param Union[int, Snowflake, Guild] guild_id: The guild id to delete the emoji from + :param Optional[str] reason: The reason for the deletion """ if not self._client: raise LibraryException(code=13) From d69c1f2a34fc4824481c8e54f87ca0790061bea1 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Wed, 5 Oct 2022 23:04:00 +0100 Subject: [PATCH 12/32] update guild.py --- interactions/api/models/guild.py | 791 +++++++++++-------------------- 1 file changed, 287 insertions(+), 504 deletions(-) diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index 565352eed..0a2671b04 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -147,8 +147,8 @@ class WelcomeChannels(DictSerializerMixin): :ivar Snowflake channel_id: The ID of the welcome channel. :ivar str description: The description of the welcome channel. - :ivar Optional[Snowflake] emoji_id?: The ID of the emoji of the welcome channel. - :ivar Optional[str] emoji_name?: The name of the emoji of the welcome channel. + :ivar Optional[Snowflake] emoji_id: The ID of the emoji of the welcome channel. + :ivar Optional[str] emoji_name: The name of the emoji of the welcome channel. """ channel_id: int = field() @@ -162,12 +162,7 @@ class WelcomeScreen(DictSerializerMixin): """ A class object representing the welcome screen shown for community guilds. - .. note:: - ``description`` is ambiguous -- Discord poorly documented this. :) - - We assume it's for the welcome screen topic. - - :ivar Optional[str] description?: The description of the welcome screen. + :ivar Optional[str] description: The description of the welcome screen. :ivar List[WelcomeChannels] welcome_channels: A list of welcome channels of the welcome screen. """ @@ -221,16 +216,11 @@ class AsyncMembersIterator(DiscordPaginationIterator): """ A class object that allows iterating through a channel's history. - :param _client: The HTTPClient of the bot - :type _client: HTTPClient - :param obj: The guild to get the members from - :type obj: Union[int, str, Snowflake, Guild] - :param start_at?: The member ID to start getting members from (gets all members after that member) - :type start_at?: Optional[Union[int, str, Snowflake, Member]] - :param check?: A check to ignore certain members - :type check?: Optional[Callable[[Member], bool]] - :param maximum?: A set maximum of members to get before stopping the iteration - :type maximum?: Optional[int] + :param HTTPClient _client: The HTTPClient of the bot + :param Union[int, str, Snowflake, Guild] obj: The guild to get the members from + :param Optional[Union[int, str, Snowflake, Member]] start_at: The member ID to start getting members from (gets all members after that member) + :param Optional[Callable[[Member], bool]] check: A check to ignore certain members + :param Optional[int] maximum: A set maximum of members to get before stopping the iteration """ def __init__( @@ -284,7 +274,7 @@ async def get_objects(self) -> None: self.objects.extend([Member(**member, _client=self._client) for member in members]) async def flatten(self) -> List[Member]: - """returns all remaining items as list""" + """Returns all remaining items of the iterator as list.""" return [item async for item in self] async def __anext__(self) -> Member: @@ -331,18 +321,18 @@ class Guild(ClientSerializerMixin, IDMixin): :ivar Snowflake id: The ID of the guild. :ivar str name: The name of the guild. - :ivar Optional[str] icon?: The icon of the guild. - :ivar Optional[str] icon_hash?: The hashed version of the icon of the guild. - :ivar Optional[str] splash?: The invite splash banner of the guild. - :ivar Optional[str] discovery_splash?: The discovery splash banner of the guild. - :ivar Optional[bool] owner?: Whether the guild is owned. + :ivar Optional[str] icon: The icon of the guild. + :ivar Optional[str] icon_hash: The hashed version of the icon of the guild. + :ivar Optional[str] splash: The invite splash banner of the guild. + :ivar Optional[str] discovery_splash: The discovery splash banner of the guild. + :ivar Optional[bool] owner: Whether the guild is owned. :ivar Snowflake owner_id: The ID of the owner of the guild. - :ivar Optional[str] permissions?: The permissions of the guild. - :ivar Optional[str] region?: The geographical region of the guild. - :ivar Optional[Snowflake] afk_channel_id?: The AFK voice channel of the guild. + :ivar Optional[str] permissions: The permissions of the guild. + :ivar Optional[str] region: The geographical region of the guild. + :ivar Optional[Snowflake] afk_channel_id: The AFK voice channel of the guild. :ivar int afk_timeout: The timeout of the AFK voice channel of the guild. - :ivar Optional[bool] widget_enabled?: Whether widgets are enabled in the guild. - :ivar Optional[Snowflake] widget_channel_id?: The channel ID of the widget in the guild. + :ivar Optional[bool] widget_enabled: Whether widgets are enabled in the guild. + :ivar Optional[Snowflake] widget_channel_id: The channel ID of the widget in the guild. :ivar int verification_level: The level of user verification of the guild. :ivar int default_message_notifications: The default message notifications setting of the guild. :ivar int explicit_content_filter: The explicit content filter setting level of the guild. @@ -350,34 +340,34 @@ class Guild(ClientSerializerMixin, IDMixin): :ivar List[Emoji] emojis: The list of emojis from the guild. :ivar List[GuildFeature] features: The list of features of the guild. :ivar int mfa_level: The MFA level of the guild. - :ivar Optional[Snowflake] application_id?: The application ID of the guild. - :ivar Optional[Snowflake] system_channel_id?: The channel ID of the system of the guild. - :ivar Optional[Snowflake] rules_channel_id?: The channel ID of Discord's defined "rules" channel of the guild. - :ivar Optional[datetime] joined_at?: The timestamp the member joined the guild. - :ivar Optional[bool] large?: Whether the guild is considered "large." - :ivar Optional[bool] unavailable?: Whether the guild is unavailable to access. - :ivar Optional[int] member_count?: The amount of members in the guild. - :ivar Optional[List[Member]] members?: The members in the guild. - :ivar Optional[List[Channel]] channels?: The channels in the guild. - :ivar Optional[List[Thread]] threads?: All known threads in the guild. - :ivar Optional[List[PresenceUpdate]] presences?: The list of presences in the guild. - :ivar Optional[int] max_presences?: The maximum amount of presences allowed in the guild. - :ivar Optional[int] max_members?: The maximum amount of members allowed in the guild. - :ivar Optional[str] vanity_url_code?: The vanity URL of the guild. - :ivar Optional[str] description?: The description of the guild. - :ivar Optional[str] banner?: The banner of the guild. + :ivar Optional[Snowflake] application_id: The application ID of the guild. + :ivar Optional[Snowflake] system_channel_id: The channel ID of the system of the guild. + :ivar Optional[Snowflake] rules_channel_id: The channel ID of Discord's defined "rules" channel of the guild. + :ivar Optional[datetime] joined_at: The timestamp the member joined the guild. + :ivar Optional[bool] large: Whether the guild is considered "large." + :ivar Optional[bool] unavailable: Whether the guild is unavailable to access. + :ivar Optional[int] member_count: The amount of members in the guild. + :ivar Optional[List[Member]] members: The members in the guild. + :ivar Optional[List[Channel]] channels: The channels in the guild. + :ivar Optional[List[Thread]] threads: All known threads in the guild. + :ivar Optional[List[PresenceUpdate]] presences: The list of presences in the guild. + :ivar Optional[int] max_presences: The maximum amount of presences allowed in the guild. + :ivar Optional[int] max_members: The maximum amount of members allowed in the guild. + :ivar Optional[str] vanity_url_code: The vanity URL of the guild. + :ivar Optional[str] description: The description of the guild. + :ivar Optional[str] banner: The banner of the guild. :ivar int premium_tier: The server boost level of the guild. - :ivar Optional[int] premium_subscription_count?: The amount of server boosters in the guild. + :ivar Optional[int] premium_subscription_count: The amount of server boosters in the guild. :ivar str preferred_locale: The "preferred" local region of the guild. - :ivar Optional[Snowflake] public_updates_channel_id?: The channel ID for community updates of the guild. - :ivar Optional[int] max_video_channel_users?: The maximum amount of video streaming members in a channel allowed in a guild. - :ivar Optional[int] approximate_member_count?: The approximate amount of members in the guild. - :ivar Optional[int] approximate_presence_count?: The approximate amount of presences in the guild. - :ivar Optional[WelcomeScreen] welcome_screen?: The welcome screen of the guild. + :ivar Optional[Snowflake] public_updates_channel_id: The channel ID for community updates of the guild. + :ivar Optional[int] max_video_channel_users: The maximum amount of video streaming members in a channel allowed in a guild. + :ivar Optional[int] approximate_member_count: The approximate amount of members in the guild. + :ivar Optional[int] approximate_presence_count: The approximate amount of presences in the guild. + :ivar Optional[WelcomeScreen] welcome_screen: The welcome screen of the guild. :ivar int nsfw_level: The NSFW safety filter level of the guild. - :ivar Optional[List[StageInstance]] stage_instances?: The stage instance of the guild. - :ivar Optional[List[Sticker]] stickers?: The list of stickers from the guild. - :ivar Optional[bool] premium_progress_bar_enabled?: Whether the guild has the boost progress bar enabled. + :ivar Optional[List[StageInstance]] stage_instances: The stage instance of the guild. + :ivar Optional[List[Sticker]] stickers: The list of stickers from the guild. + :ivar Optional[bool] premium_progress_bar_enabled: Whether the guild has the boost progress bar enabled. """ id: Snowflake = field(converter=Snowflake) @@ -494,18 +484,12 @@ async def ban( """ Bans a member from the guild. - :param member_id: The id of the member to ban - :type member_id: Union[int, Member, Snowflake] - :param seconds?: Number of seconds to delete messages, from 0 to 604800. Defaults to 0 - :type seconds?: Optional[int] - :param minutes?: Number of minutes to delete messages, from 0 to 10080 - :type minutes?: Optional[int] - :param hours?: Number of hours to delete messages, from 0 to 168 - :type hours?: Optional[int] - :param days?: Number of days to delete messages, from 0 to 7 - :type days?: Optional[int] - :param reason?: The reason of the ban - :type reason?: Optional[str] + :param Union[int, Member, Snowflake] member_id: The id of the member to ban + :param Optional[int] seconds: Number of seconds to delete messages, from 0 to 604800. Defaults to 0 + :param Optional[int] minutes: Number of minutes to delete messages, from 0 to 10080 + :param Optional[int] hours: Number of hours to delete messages, from 0 to 168 + :param Optional[int] days: Number of days to delete messages, from 0 to 7 + :param Optional[str] reason: The reason of the ban """ if not self._client: raise LibraryException(code=13) @@ -545,10 +529,8 @@ async def remove_ban( """ Removes the ban of a user. - :param user_id: The id of the user to remove the ban from - :type user_id: Union[int, Snowflake] - :param reason?: The reason for the removal of the ban - :type reason?: Optional[str] + :param Union[int, Snowflake] user_id: The id of the user to remove the ban from + :param Optional[str] reason: The reason for the removal of the ban """ if not self._client: raise LibraryException(code=13) @@ -566,10 +548,8 @@ async def kick( """ Kicks a member from the guild. - :param member_id: The id of the member to kick - :type member_id: Union[int, Member, Snowflake] - :param reason?: The reason for the kick - :type reason?: Optional[str] + :param Union[int, Member, Snowflake] member_id: The id of the member to kick + :param Optional[str] reason: The reason for the kick """ if not self._client: raise LibraryException(code=13) @@ -593,12 +573,9 @@ async def add_member_role( """ This method adds a role to a member. - :param role: The role to add. Either ``Role`` object or role_id - :type role: Union[Role, int, Snowflake] - :param member_id: The id of the member to add the roles to - :type member_id: Union[Member, int, Snowflake] - :param reason?: The reason why the roles are added - :type reason?: Optional[str] + :param Union[Role, int, Snowflake] role: The role to add. Either ``Role`` object or role_id + :param Union[Member, int, Snowflake] member_id: The id of the member to add the roles to + :param Optional[str] reason: The reason why the roles are added """ if not self._client: raise LibraryException(code=13) @@ -622,12 +599,9 @@ async def remove_member_role( """ This method removes a or multiple role(s) from a member. - :param role: The role to remove. Either ``Role`` object or role_id - :type role: Union[Role, int, Snowflake] - :param member_id: The id of the member to remove the roles from - :type member_id: Union[Member, int, Snowflake] - :param reason?: The reason why the roles are removed - :type reason?: Optional[str] + :param Union[Role, int, Snowflake] role: The role to remove. Either ``Role`` object or role_id + :param Union[Member, int, Snowflake] member_id: The id of the member to remove the roles from + :param Optional[str] reason: The reason why the roles are removed """ if not self._client: raise LibraryException(code=13) @@ -656,22 +630,14 @@ async def create_role( """ Creates a new role in the guild. - :param name: The name of the role - :type name: str - :param color?: RGB color value as integer, default ``0`` - :type color?: Optional[int] - :param permissions?: Bitwise value of the enabled/disabled permissions - :type permissions?: Optional[int] - :param hoist?: Whether the role should be displayed separately in the sidebar, default ``False`` - :type hoist?: Optional[bool] - :param icon?: The role's icon image (if the guild has the ROLE_ICONS feature) - :type icon?: Optional[Image] - :param unicode_emoji?: The role's unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature) - :type unicode_emoji?: Optional[str] - :param mentionable?: Whether the role should be mentionable, default ``False`` - :type mentionable?: Optional[bool] - :param reason?: The reason why the role is created, default ``None`` - :type reason?: Optional[str] + :param str name: The name of the role + :param Optional[int] color: RGB color value as integer, default ``0`` + :param Optional[int] permissions: Bitwise value of the enabled/disabled permissions + :param Optional[bool] hoist: Whether the role should be displayed separately in the sidebar, default ``False`` + :param Optional[Image] icon: The role's icon image (if the guild has the ROLE_ICONS feature) + :param Optional[str] unicode_emoji: The role's unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature) + :param Optional[bool] mentionable: Whether the role should be mentionable, default ``False`` + :param Optional[str] reason: The reason why the role is created, default ``None`` :return: The created Role :rtype: Role """ @@ -707,8 +673,7 @@ async def get_member( """ Searches for the member with specified id in the guild and returns the member as member object. - :param member_id: The id of the member to search for - :type member_id: Union[int, Snowflake] + :param Union[int, Snowflake] member_id: The id of the member to search for :return: The member searched for :rtype: Member """ @@ -736,8 +701,7 @@ async def delete_channel( """ Deletes a channel from the guild. - :param channel_id: The id of the channel to delete - :type channel_id: Union[int, Snowflake, Channel] + :param Union[int, Snowflake, Channel] channel_id: The id of the channel to delete """ if not self._client: raise LibraryException(code=13) @@ -759,10 +723,8 @@ async def delete_role( """ Deletes a role from the guild. - :param role_id: The id of the role to delete - :type role_id: Union[int, Snowflake, Role] - :param reason?: The reason of the deletion - :type reason?: Optional[str] + :param Union[int, Snowflake, Role] role_id: The id of the role to delete + :param Optional[str] reason: The reason of the deletion """ if not self._client: raise LibraryException(code=13) @@ -796,24 +758,15 @@ async def modify_role( """ Edits a role in the guild. - :param role_id: The id of the role to edit - :type role_id: Union[int, Snowflake, Role] - :param name?: The name of the role, defaults to the current value of the role - :type name?: Optional[str] - :param color?: RGB color value as integer, defaults to the current value of the role - :type color?: Optional[int] - :param permissions?: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role - :type permissions?: Optional[int] - :param hoist?: Whether the role should be displayed separately in the sidebar, defaults to the current value of the role - :type hoist?: Optional[bool] - :param icon?: The role's icon image (if the guild has the ROLE_ICONS feature), defaults to the current value of the role - :type icon?: Optional[Image] - :param unicode_emoji?: The role's unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature), defaults to the current value of the role - :type unicode_emoji?: Optional[str] - :param mentionable?: Whether the role should be mentionable, defaults to the current value of the role - :type mentionable?: Optional[bool] - :param reason?: The reason why the role is edited, default ``None`` - :type reason?: Optional[str] + :param Union[int, Snowflake, Role] role_id: The id of the role to edit + :param Optional[str] name: The name of the role, defaults to the current value of the role + :param Optional[int] color: RGB color value as integer, defaults to the current value of the role + :param Optional[int] permissions: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role + :param Optional[bool] hoist: Whether the role should be displayed separately in the sidebar, defaults to the current value of the role + :param Optional[Image] icon: The role's icon image (if the guild has the ROLE_ICONS feature), defaults to the current value of the role + :param Optional[str] unicode_emoji: The role's unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature), defaults to the current value of the role + :param Optional[bool] mentionable: Whether the role should be mentionable, defaults to the current value of the role + :param Optional[str] reason: The reason why the role is edited, default ``None`` :return: The modified role object :rtype: Role """ @@ -873,21 +826,13 @@ async def create_thread( """ Creates a thread in the specified channel. - :param name: The name of the thread - :type name: str - :param channel_id: The id of the channel to create the thread in - :type channel_id: Union[int, Snowflake, Channel] - :param auto_archive_duration?: duration in minutes to automatically archive the thread after recent activity, - can be set to: 60, 1440, 4320, 10080 - :type auto_archive_duration?: Optional[int] - :param type?: The type of thread, defaults to public. ignored if creating thread from a message - :type type?: Optional[ChannelType] - :param invitable?: Boolean to display if the Thread is open to join or private. - :type invitable?: Optional[bool] - :param message_id?: An optional message to create a thread from. - :type message_id?: Optional[Union[int, Snowflake, "Message"]] - :param reason?: An optional reason for the audit log - :type reason?: Optional[str] + :param str name: The name of the thread + :param Union[int, Snowflake, Channel] channel_id: The id of the channel to create the thread in + :param Optional[int] auto_archive_duration: duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 + :param Optional[ChannelType] type: The type of thread, defaults to public. ignored if creating thread from a message + :param Optional[bool] invitable: Boolean to display if the Thread is open to join or private. + :param Optional[Union[int, Snowflake, Message]] message_id: An optional message to create a thread from. + :param Optional[str] reason: An optional reason for the audit log :return: The created thread :rtype: Channel """ @@ -939,28 +884,17 @@ async def create_channel( """ Creates a channel in the guild. - :param name: The name of the channel - :type name: str - :param type: The type of the channel - :type type: ChannelType - :param topic?: The topic of that channel - :type topic?: Optional[str] - :param bitrate?: (voice channel only) The bitrate (in bits) of the voice channel - :type bitrate?: Optional[int] - :param user_limit?: (voice channel only) Maximum amount of users in the channel - :type user_limit?: Optional[int] - :param rate_limit_per_use?: Amount of seconds a user has to wait before sending another message (0-21600) - :type rate_limit_per_user: Optional[int] - :param position?: Sorting position of the channel - :type position?: Optional[int] - :param parent_id?: The id of the parent category for a channel - :type parent_id?: Optional[Union[int, Channel, Snowflake]] - :param permission_overwrites?: The permission overwrites, if any - :type permission_overwrites?: Optional[Overwrite] - :param nsfw?: Whether the channel is nsfw or not, default ``False`` - :type nsfw?: Optional[bool] - :param reason: The reason for the creation - :type reason: Optional[str] + :param str name: The name of the channel + :param ChannelType type: The type of the channel + :param Optional[str] topic: The topic of that channel + :param Optional[int] bitrate: (voice channel only) The bitrate (in bits) of the voice channel + :param Optional[int] user_limit: (voice channel only) Maximum amount of users in the channel + :param Optional[int] rate_limit_per_use: Amount of seconds a user has to wait before sending another message (0-21600) + :param Optional[int] position: Sorting position of the channel + :param Optional[Union[int, Channel, Snowflake]] parent_id: The id of the parent category for a channel + :param Optional[Overwrite] permission_overwrites: The permission overwrites, if any + :param Optional[bool] nsfw: Whether the channel is nsfw or not, default ``False`` + :param Optional[str] reason: The reason for the creation :return: The created channel :rtype: Channel """ @@ -1025,8 +959,7 @@ async def clone_channel(self, channel_id: Union[int, Snowflake, Channel]) -> Cha """ Clones a channel of the guild. - :param channel_id: The id of the channel to clone - :type channel_id: Union[int, Snowflake, Channel] + :param Union[int, Snowflake, Channel] channel_id: The id of the channel to clone :return: The cloned channel :rtype: Channel """ @@ -1066,36 +999,22 @@ async def modify_channel( Edits a channel of the guild. .. note:: - The fields `archived`, `auto_archive_duration` and `locked` require the provided channel to be a thread. - - :param channel_id: The id of the channel to modify - :type channel_id: Union[int, Snowflake, Channel] - :param name?: The name of the channel, defaults to the current value of the channel - :type name?: str - :param topic?: The topic of that channel, defaults to the current value of the channel - :type topic?: Optional[str] - :param bitrate?: (voice channel only) The bitrate (in bits) of the voice channel, defaults to the current value of the channel - :type bitrate?: Optional[int] - :param user_limit?: (voice channel only) Maximum amount of users in the channel, defaults to the current value of the channel - :type user_limit?: Optional[int] - :param rate_limit_per_use?: Amount of seconds a user has to wait before sending another message (0-21600), defaults to the current value of the channel - :type rate_limit_per_user: Optional[int] - :param position?: Sorting position of the channel, defaults to the current value of the channel - :type position?: Optional[int] - :param parent_id?: The id of the parent category for a channel, defaults to the current value of the channel - :type parent_id?: Optional[int] - :param permission_overwrites?: The permission overwrites, if any - :type permission_overwrites?: Optional[Overwrite] - :param nsfw?: Whether the channel is nsfw or not, defaults to the current value of the channel - :type nsfw?: Optional[bool] - :param archived?: Whether the thread is archived - :type archived?: Optional[bool] - :param auto_archive_duration?: The time after the thread is automatically archived. One of 60, 1440, 4320, 10080 - :type auto_archive_duration?: Optional[int] - :param locked?: Whether the thread is locked - :type locked?: Optional[bool] - :param reason: The reason for the edit - :type reason: Optional[str] + The fields ``archived``, ``auto_archive_duration`` and ``locked`` require the provided channel to be a thread. + + :param Union[int, Snowflake, Channel] channel_id: The id of the channel to modify + :param str name: The name of the channel, defaults to the current value of the channel + :param Optional[str] topic: The topic of that channel, defaults to the current value of the channel + :param Optional[int] bitrate: (voice channel only) The bitrate (in bits) of the voice channel, defaults to the current value of the channel + :param Optional[int] user_limit: (voice channel only) Maximum amount of users in the channel, defaults to the current value of the channel + :param Optional[int] rate_limit_per_use: Amount of seconds a user has to wait before sending another message (0-21600), defaults to the current value of the channel + :param position: Sorting position of the channel, defaults to the current value of the channel + :param parent_id: The id of the parent category for a channel, defaults to the current value of the channel + :param Optional[Overwrite] permission_overwrites: The permission overwrites, if any + :param Optional[bool] nsfw: Whether the channel is nsfw or not, defaults to the current value of the channel + :param Optional[bool] archived: Whether the thread is archived + :param Optional[int] auto_archive_duration: The time after the thread is automatically archived. One of 60, 1440, 4320, 10080 + :param Optional[bool] locked: Whether the thread is locked + :param Optional[str] reason: The reason for the edit :return: The modified channel :rtype: Channel """ @@ -1189,22 +1108,14 @@ async def modify_member( """ Modifies a member of the guild. - :param member_id: The id of the member to modify - :type member_id: Union[int, Snowflake, Member] - :param nick?: The nickname of the member - :type nick?: Optional[str] - :param roles?: A list of all role ids the member has - :type roles?: Optional[List[int]] - :param mute?: whether the user is muted in voice channels - :type mute?: Optional[bool] - :param deaf?: whether the user is deafened in voice channels - :type deaf?: Optional[bool] - :param channel_id?: id of channel to move user to (if they are connected to voice) - :type channel_id?: Optional[int] - :param communication_disabled_until?: when the user's timeout will expire and the user will be able to communicate in the guild again (up to 28 days in the future) - :type communication_disabled_until?: Optional[datetime.isoformat] - :param reason?: The reason of the modifying - :type reason?: Optional[str] + :param Union[int, Snowflake, Member] member_id: The id of the member to modify + :param Optional[str] nick: The nickname of the member + :param Optional[List[int]] roles: A list of all role ids the member has + :param Optional[bool] mute: whether the user is muted in voice channels + :param Optional[bool] deaf: whether the user is deafened in voice channels + :param Optional[int] channel_id: id of channel to move user to (if they are connected to voice) + :param Optional[datetime.isoformat] communication_disabled_until: when the user's timeout will expire and the user will be able to communicate in the guild again (up to 28 days in the future) + :param Optional[str] reason: The reason of the modifying :return: The modified member :rtype: Member """ @@ -1298,50 +1209,28 @@ async def modify( """ Modifies the current guild. - :param name?: The new name of the guild - :type name?: Optional[str] - :param verification_level?: The verification level of the guild - :type verification_level?: Optional[VerificationLevel] - :param default_message_notifications?: The default message notification level for members - :type default_message_notifications?: Optional[DefaultMessageNotificationLevel] - :param explicit_content_filter?: The explicit content filter level for media content - :type explicit_content_filter?: Optional[ExplicitContentFilterLevel] - :param afk_channel_id?: The id for the afk voice channel - :type afk_channel_id?: Optional[int] - :param afk_timeout?: Afk timeout in seconds - :type afk_timeout?: Optional[int] - :param icon?: 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the server has the ANIMATED_ICON feature) - :type icon?: Optional[Image] - :param owner_id?: The id of the user to transfer the guild ownership to. You must be the owner to perform this - :type owner_id?: Optional[int] - :param splash?: 16:9 png/jpeg image for the guild splash (when the server has the INVITE_SPLASH feature) - :type splash?: Optional[Image] - :param discovery_splash?: 16:9 png/jpeg image for the guild discovery splash (when the server has the DISCOVERABLE feature) - :type discovery_splash?: Optional[Image] - :param banner?: 16:9 png/jpeg image for the guild banner (when the server has the BANNER feature; can be animated gif when the server has the ANIMATED_BANNER feature) - :type banner?: Optional[Image] - :param system_channel_id?: The id of the channel where guild notices such as welcome messages and boost events are posted - :type system_channel_id?: Optional[int] - :param suppress_join_notifications?: Whether to suppress member join notifications in the system channel or not - :type suppress_join_notifications?: Optional[bool] - :param suppress_premium_subscriptions?: Whether to suppress server boost notifications in the system channel or not - :type suppress_premium_subscriptions?: Optional[bool] - :param suppress_guild_reminder_notifications?: Whether to suppress server setup tips in the system channel or not - :type suppress_guild_reminder_notifications?: Optional[bool] - :param suppress_join_notification_replies?: Whether to hide member join sticker reply buttons in the system channel or not - :type suppress_join_notification_replies?: Optional[bool] - :param rules_channel_id?: The id of the channel where guilds display rules and/or guidelines - :type rules_channel_id?: Optional[int] - :param public_updates_channel_id?: The id of the channel where admins and moderators of community guilds receive notices from Discord - :type public_updates_channel_id?: Optional[int] - :param preferred_locale?: The preferred locale of a community guild used in server discovery and notices from Discord; defaults to "en-US" - :type preferred_locale?: Optional[str] - :param description?: The description for the guild, if the guild is discoverable - :type description?: Optional[str] - :param premium_progress_bar_enabled?: Whether the guild's boost progress bar is enabled - :type premium_progress_bar_enabled?: Optional[bool] - :param reason?: The reason for the modifying - :type reason?: Optional[str] + :param Optional[str] name: The new name of the guild + :param Optional[VerificationLevel] verification_level: The verification level of the guild + :param Optional[DefaultMessageNotificationLevel] default_message_notifications: The default message notification level for members + :param Optional[ExplicitContentFilterLevel] explicit_content_filter: The explicit content filter level for media content + :param Optional[int] afk_channel_id: The id for the afk voice channel + :param Optional[int] afk_timeout: Afk timeout in seconds + :param Optional[Image] icon: 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the server has the ANIMATED_ICON feature) + :param Optional[int] owner_id: The id of the user to transfer the guild ownership to. You must be the owner to perform this + :param Optional[Image] splash: 16:9 png/jpeg image for the guild splash (when the server has the INVITE_SPLASH feature) + :param Optional[Image] discovery_splash: 16:9 png/jpeg image for the guild discovery splash (when the server has the DISCOVERABLE feature) + :param Optional[Image] banner: 16:9 png/jpeg image for the guild banner (when the server has the BANNER feature; can be animated gif when the server has the ANIMATED_BANNER feature) + :param Optional[int] system_channel_id: The id of the channel where guild notices such as welcome messages and boost events are posted + :param Optional[bool] suppress_join_notifications: Whether to suppress member join notifications in the system channel or not + :param Optional[bool] suppress_premium_subscriptions: Whether to suppress server boost notifications in the system channel or not + :param Optional[bool] suppress_guild_reminder_notifications: Whether to suppress server setup tips in the system channel or not + :param Optional[bool] suppress_join_notification_replies: Whether to hide member join sticker reply buttons in the system channel or not + :param Optional[int] rules_channel_id: The id of the channel where guilds display rules and/or guidelines + :param Optional[int] public_updates_channel_id: The id of the channel where admins and moderators of community guilds receive notices from Discord + :param Optional[str] preferred_locale: The preferred locale of a community guild used in server discovery and notices from Discord; defaults to "en-US" + :param Optional[str] description: The description for the guild, if the guild is discoverable + :param Optional[bool] premium_progress_bar_enabled: Whether the guild's boost progress bar is enabled + :param Optional[str] reason: The reason for the modifying :return: The modified guild :rtype: Guild """ @@ -1433,10 +1322,8 @@ async def set_name( """ Sets the name of the guild. - :param name: The new name of the guild - :type name: str - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param str name: The new name of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(name=name, reason=reason) @@ -1449,10 +1336,8 @@ async def set_verification_level( """ Sets the verification level of the guild. - :param verification_level: The new verification level of the guild - :type verification_level: VerificationLevel - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param VerificationLevel verification_level: The new verification level of the guild + :param Optional[str] reason?: The reason of the edit """ return await self.modify(verification_level=verification_level, reason=reason) @@ -1465,10 +1350,8 @@ async def set_default_message_notifications( """ Sets the default message notifications level of the guild. - :param default_message_notifications: The new default message notification level of the guild - :type default_message_notifications: DefaultMessageNotificationLevel - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param DefaultMessageNotificationLevel default_message_notifications: The new default message notification level of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify( default_message_notifications=default_message_notifications, reason=reason @@ -1483,10 +1366,8 @@ async def set_explicit_content_filter( """ Sets the explicit content filter level of the guild. - :param explicit_content_filter: The new explicit content filter level of the guild - :type explicit_content_filter: ExplicitContentFilterLevel - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param ExplicitContentFilterLevel explicit_content_filter: The new explicit content filter level of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(explicit_content_filter=explicit_content_filter, reason=reason) @@ -1499,10 +1380,8 @@ async def set_afk_channel( """ Sets the afk channel of the guild. - :param afk_channel_id: The new name of the guild - :type afk_channel_id: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int afk_channel_id: The new name of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(afk_channel_id=afk_channel_id, reason=reason) @@ -1515,10 +1394,8 @@ async def set_afk_timeout( """ Sets the afk timeout of the guild. - :param afk_timeout: The new afk timeout of the guild - :type afk_timeout: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int afk_timeout: The new afk timeout of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(afk_timeout=afk_timeout, reason=reason) @@ -1531,10 +1408,8 @@ async def set_system_channel( """ Sets the system channel of the guild. - :param system_channel_id: The new system channel id of the guild - :type system_channel_id: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int system_channel_id: The new system channel id of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(system_channel_id=system_channel_id, reason=reason) @@ -1547,10 +1422,8 @@ async def set_rules_channel( """ Sets the rules channel of the guild. - :param rules_channel_id: The new rules channel id of the guild - :type rules_channel_id: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int rules_channel_id: The new rules channel id of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(rules_channel_id=rules_channel_id, reason=reason) @@ -1563,10 +1436,8 @@ async def set_public_updates_channel( """ Sets the public updates channel of the guild. - :param public_updates_channel_id: The new public updates channel id of the guild - :type public_updates_channel_id: int - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param int public_updates_channel_id: The new public updates channel id of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(public_updates_channel_id=public_updates_channel_id, reason=reason) @@ -1579,10 +1450,8 @@ async def set_preferred_locale( """ Sets the preferred locale of the guild. - :param preferred_locale: The new preferredlocale of the guild - :type preferred_locale: str - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param str preferred_locale: The new preferredlocale of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(preferred_locale=preferred_locale, reason=reason) @@ -1595,10 +1464,8 @@ async def set_description( """ Sets the description of the guild. - :param description: The new description of the guild - :type description: str - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param str description: The new description of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(description=description, reason=reason) @@ -1611,10 +1478,8 @@ async def set_premium_progress_bar_enabled( """ Sets the visibility of the premium progress bar of the guild. - :param premium_progress_bar_enabled: Whether the bar is enabled or not - :type premium_progress_bar_enabled: bool - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param bool premium_progress_bar_enabled: Whether the bar is enabled or not + :param Optional[str] reason: The reason of the edit """ return await self.modify( premium_progress_bar_enabled=premium_progress_bar_enabled, reason=reason @@ -1629,10 +1494,8 @@ async def set_icon( """ Sets the icon of the guild. - :param icon: The new icon of the guild - :type icon: Image - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param Image icon: The new icon of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(icon=icon, reason=reason) @@ -1645,10 +1508,8 @@ async def set_splash( """ Sets the splash of the guild. - :param splash: The new splash of the guild - :type splash: Image - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param Image splash: The new splash of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(splash=splash, reason=reason) @@ -1661,10 +1522,8 @@ async def set_discovery_splash( """ Sets the discovery_splash of the guild. - :param discovery_splash: The new discovery_splash of the guild - :type discovery_splash: Image - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param Image discovery_splash: The new discovery_splash of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(discovery_splash=discovery_splash, reason=reason) @@ -1677,10 +1536,8 @@ async def set_banner( """ Sets the banner of the guild. - :param banner: The new banner of the guild - :type banner: Image - :param reason?: The reason of the edit - :type reason?: Optional[str] + :param Image banner: The new banner of the guild + :param Optional[str] reason: The reason of the edit """ return await self.modify(banner=banner, reason=reason) @@ -1697,24 +1554,16 @@ async def create_scheduled_event( # privacy_level, TODO: implement when more levels available ) -> "ScheduledEvents": """ - creates a scheduled event for the guild. - - :param name: The name of the event - :type name: str - :param entity_type: The entity type of the scheduled event - :type entity_type: EntityType - :param scheduled_start_time: The time to schedule the scheduled event - :type scheduled_start_time: datetime.isoformat - :param scheduled_end_time?: The time when the scheduled event is scheduled to end - :type scheduled_end_time?: Optional[datetime.isoformat] - :param entity_metadata?: The entity metadata of the scheduled event - :type entity_metadata?: Optional[EventMetadata] - :param channel_id?: The channel id of the scheduled event. - :type channel_id?: Optional[int] - :param description?: The description of the scheduled event - :type description?: Optional[str] - :param image?: The cover image of the scheduled event - :type image?: Optional[Image] + Creates a scheduled event for the guild. + + :param str name: The name of the event + :param EntityType entity_type: The entity type of the scheduled event + :param datetime.isoformat scheduled_start_time: The time to schedule the scheduled event + :param Optional[datetime.isoformat] scheduled_end_time: The time when the scheduled event is scheduled to end + :param Optional[EventMetadata] entity_metadata: The entity metadata of the scheduled event + :param Optional[int] channel_id: The channel id of the scheduled event. + :param Optional[str] description: The description of the scheduled event + :param Optional[Image] image: The cover image of the scheduled event :return: The created event :rtype: ScheduledEvents """ @@ -1759,8 +1608,7 @@ async def get_scheduled_events(self, with_user_count: bool) -> List["ScheduledEv """ Gets all scheduled events of the guild. - :param with_user_count: A boolean to include number of users subscribed to the associated event, if given. - :type with_user_count: bool + :param bool with_user_count: A boolean to include number of users subscribed to the associated event, if given. :return: The sheduled events of the guild. :rtype: List[ScheduledEvents] """ @@ -1788,26 +1636,16 @@ async def modify_scheduled_event( """ Edits a scheduled event of the guild. - :param event_id: The id of the event to edit - :type event_id: Union[int, "ScheduledEvents", Snowflake] - :param name: The name of the event - :type name: Optional[str] - :param entity_type: The entity type of the scheduled event - :type entity_type: Optional[EntityType] - :param scheduled_start_time: The time to schedule the scheduled event - :type scheduled_start_time: Optional[datetime.isoformat] - :param scheduled_end_time?: The time when the scheduled event is scheduled to end - :type scheduled_end_time?: Optional[datetime.isoformat] - :param entity_metadata?: The entity metadata of the scheduled event - :type entity_metadata?: Optional[EventMetadata] - :param channel_id?: The channel id of the scheduled event. - :type channel_id?: Optional[int] - :param description?: The description of the scheduled event - :type description?: Optional[str] - :param status?: The status of the scheduled event - :type status?: Optional[EventStatus] - :param image?: The cover image of the scheduled event - :type image?: Optional[Image] + :param Union[int, ScheduledEvents, Snowflake] event_id: The id of the event to edit + :param Optional[str] name: The name of the event + :param Optional[EntityType] entity_type: The entity type of the scheduled event + :param Optional[datetime.isoformat] scheduled_start_time: The time to schedule the scheduled event + :param Optional[datetime.isoformat] scheduled_end_time: The time when the scheduled event is scheduled to end + :param Optional[EventMetadata] entity_metadata: The entity metadata of the scheduled event + :param Optional[int] channel_id: The channel id of the scheduled event. + :param Optional[str] description: The description of the scheduled event + :param Optional[EventStatus] status: The status of the scheduled event + :param Optional[Image] image: The cover image of the scheduled event :return: The modified event :rtype: ScheduledEvents """ @@ -1854,8 +1692,7 @@ async def delete_scheduled_event( """ Deletes a scheduled event of the guild. - :param event_id: The id of the event to delete - :type event_id: Union[int, "ScheduledEvents", Snowflake] + :param Union[int, ScheduledEvents, Snowflake] event_id: The id of the event to delete """ if not self._client: raise LibraryException(code=13) @@ -1920,8 +1757,7 @@ async def get_role( """ Gets a role of the guild. - :param role_id: The id of the role to get - :type role_id: int + :param int role_id: The id of the role to get :return: The role as object :rtype: Role """ @@ -1949,12 +1785,9 @@ async def modify_role_position( """ Modifies the position of a role in the guild. - :param role_id: The id of the role to modify the position of - :type role_id: Union[Role, int] - :param position: The new position of the role - :type position: int - :param reason?: The reason for the modifying - :type reason?: Optional[str] + :param Union[Role, int] role_id: The id of the role to modify the position of + :param int position: The new position of the role + :param Optional[str] reason: The reason for the modifying :return: List of guild roles with updated hierarchy :rtype: List[Role] """ @@ -1973,10 +1806,8 @@ async def modify_role_positions( """ Modifies the positions of multiple roles in the guild. - :param changes: A list of dicts containing roles (id) and their new positions (position) - :type changes: List[dict] - :param reason: The reason for the modifying - :type reason: Optional[str] + :param List[dict] changes: A list of dicts containing roles (id) and their new positions (position) + :param Optional[str] reason: The reason for the modifying :return: List of guild roles with updated hierarchy :rtype: List[Role] """ @@ -2004,12 +1835,9 @@ async def get_bans( """ Gets a list of banned users. - :param limit?: Number of users to return. Defaults to 1000. - :type limit?: Optional[int] - :param before?: Consider only users before the given User ID snowflake. - :type before?: Optional[int] - :param after?: Consider only users after the given User ID snowflake. - :type after?: Optional[int] + :param Optional[int] limit: Number of users to return. Defaults to 1000. + :param Optional[int] before: Consider only users before the given User ID snowflake. + :param Optional[int] after: Consider only users after the given User ID snowflake. :return: List of banned users with reasons :rtype: List[Dict[str, User]] """ @@ -2065,9 +1893,9 @@ async def prune( """ Begins a prune operation. - :param days: Number of days to count, minimum 1, maximum 30. Defaults to 7. - :param compute_prune_count: Whether the returned "pruned" dict contains the computed prune count or None. - :param include_roles: Role IDs to include, if given. + :param Optional[int] days: Number of days to count, minimum 1, maximum 30. Defaults to 7. + :param Optional[bool] compute_prune_count: Whether the returned "pruned" dict contains the computed prune count or None. + :param Optional[Union[List[Role], List[int], List[Snowflake], List[str]]] include_roles: Role IDs to include, if given. :return: The number of pruned members, if compute_prune_count is not false. Otherwise returns None. :rtype: Optional[int] """ @@ -2098,8 +1926,8 @@ async def get_prune_count( """ Returns the number of members that would be removed in a prune operation. - :param days: Number of days to count, minimum 1, maximum 30. Defaults to 7. - :param include_roles: Role IDs to include, if given. + :param Optional[int] days: Number of days to count, minimum 1, maximum 30. Defaults to 7. + :param Optional[Union[List[Role], List[int], List[Snowflake], List[str]]] include_roles: Role IDs to include, if given. :return: The number of members that would be pruned. :rtype: int """ @@ -2128,8 +1956,7 @@ async def get_emoji( """ Gets an emoji of the guild and returns it. - :param emoji_id: The id of the emoji - :type emoji_id: int + :param int emoji_id: The id of the emoji :return: The specified Emoji, if found :rtype: Emoji """ @@ -2173,14 +2000,10 @@ async def create_emoji( """ Creates an Emoji in the guild. - :param image: The image of the emoji. - :type image: Image - :param name?: The name of the emoji. If not specified, the filename will be used - :type name?: Optional[str] - :param roles?: Roles allowed to use this emoji - :type roles?: Optional[Union[List[Role], List[int]]] - :param reason?: The reason of the creation - :type reason?: Optional[str] + :param Image image: The image of the emoji. + :param Optional[str] name: The name of the emoji. If not specified, the filename will be used + :param Optional[Union[List[Role], List[int]]] roles: Roles allowed to use this emoji + :param Optional[str] reason: The reason of the creation """ if not self._client: raise LibraryException(code=13) @@ -2215,10 +2038,8 @@ async def delete_emoji( """ Deletes an emoji of the guild. - :param emoji: The emoji or the id of the emoji to delete - :type emoji: Union[Emoji, int] - :param reason?: The reason of the deletion - :type reason?: Optional[str] + :param Union[Emoji, int] emoji: The emoji or the id of the emoji to delete + :param Optional[str] reason: The reason of the deletion """ if not self._client: raise LibraryException(code=13) @@ -2277,16 +2098,11 @@ async def create_sticker( """ Creates a new sticker for the guild. - :param file: The file of the sticker. - :type file: File - :param tags: The tags of the sticker. - :type tags: str - :param name?: The name of the sticker. - :type name?: Optional[str] - :param description?: The description of the sticker. - :type description?: Optional[str] - :param reason?: The reason of the creation. - :type reason?: Optional[str] + :param File file: The file of the sticker. + :param str tags: The tags of the sticker. + :param Optional[str] name: The name of the sticker. + :param Optional[str] description: The description of the sticker. + :param Optional[str] reason: The reason of the creation. :return: Created sticker for the guild. :rtype: Sticker """ @@ -2322,14 +2138,10 @@ async def modify_sticker( """ Modifies the sticker of the guild. - :param sticker_id: The sticker or ID of the sticker. - :type sticker_id: Union[Sticker, Snowflake, int] - :param name?: The name of the sticker. - :type name?: Optional[str] - :param description?: The description of the sticker. - :type description?: Optional[str] - :param reason?: The reason of the modification. - :type reason?: Optional[str] + :param Union[Sticker, Snowflake, int] sticker_id: The sticker or ID of the sticker. + :param Optional[str] name: The name of the sticker. + :param Optional[str] description: The description of the sticker. + :param Optional[str] reason: The reason of the modification. :return: Modified sticker. :rtype: Sticker """ @@ -2366,10 +2178,8 @@ async def delete_sticker( ): """Deletes the sticker of the guild. - :param sticker_id: The sticker or ID of the sticker. - :type sticker_id: Union[Sticker, Snowflake, int] - :param reason?: The reason of the deletion. - :type reason?: Optional[str] + :param Union[Sticker, Snowflake, int] sticker_id: The sticker or ID of the sticker. + :param Optional[str] reason: The reason of the deletion. """ if not self._client: raise LibraryException(code=13) @@ -2395,10 +2205,8 @@ async def get_list_of_members( """ Lists the members of a guild. - :param limit?: How many members to get from the API. Max is 1000. - :type limit?: Optional[int] - :param after?: Get only Members after this member. - :type after?: Optional[Union[Member, int]] + :param Optional[int] limit: How many members to get from the API. Max is 1000. + :param Optional[Union[Member, int]] after: Get only Members after this member. :return: A list of members :rtype: List[Member] """ @@ -2423,10 +2231,8 @@ async def search_members(self, query: str, limit: Optional[int] = 1) -> List[Mem """ Search the guild for members whose username or nickname starts with provided string. - :param query: The string to search for - :type query: str - :param limit?: The number of members to return. - :type limit?: Optional[int] + :param str query: The string to search for + :param Optional[int] limit: The number of members to return. :return: A list of matching members :rtype: List[Member] """ @@ -2477,12 +2283,9 @@ def get_members( check: Optional[Callable[[Member], bool]] = None, ) -> AsyncMembersIterator: """ - :param start_at?: The message to begin getting the history from - :type start_at?: Optional[Union[int, str, Snowflake, Member]] - :param maximum?: A set maximum of members to get before stopping the iteration - :type maximum?: Optional[int] - :param check?: A custom check to ignore certain members - :type check?: Optional[Callable[[Message], bool]] + :param Optional[Union[int, str, Snowflake, Member]] start_at: The message to begin getting the history from + :param Optional[int] maximum: A set maximum of members to get before stopping the iteration + :param Optional[Callable[[Message], bool]] check: A custom check to ignore certain members :return: An asynchronous iterator over the members of the guild :rtype: AsyncMembersIterator @@ -2495,6 +2298,9 @@ def get_members( ) async def get_webhooks(self) -> List[Webhook]: + """ + Get all webhooks of a guild. + """ if not self._client: raise LibraryException(code=13) @@ -2521,8 +2327,7 @@ async def get_auto_moderation_rule( """ Gets a AutoMod rule from its ID - :param rule_id: The ID of the rule to get - :type rule_id: Union[int, Snowflake] + :param Union[int, Snowflake] rule_id: The ID of the rule to get :return: A AutoMod rule :rtype: AutoModerationRule """ @@ -2550,22 +2355,14 @@ async def create_auto_moderation_rule( """ Creates an AutoMod rule - :param name: The name of the new rule. - :type name: str - :param trigger_type: The trigger type of the new rule. - :type trigger_type: AutoModTriggerType - :param trigger_metadata: The trigger metadata payload representation. This can be omitted based on the trigger type. - :type trigger_metadata: Optional[AutoModTriggerMetadata] - :param actions: The actions that will execute when the rule is triggered. - :type actions: List[AutoModAction] - :param enabled: Whether the rule will be enabled upon creation. False by default. - :type enabled: Optional[bool] - :param exempt_roles: The role IDs that are whitelisted by the rule, if given. The maximum is 20. - :type exempt_roles: Optional[List[int]] - :param exempt_channels: The channel IDs that are whitelisted by the rule, if given. The maximum is 20 - :type exempt_channels: Optional[List[int]] - :param reason: The reason of the creation - :type reason: Optional[str] + :param str name: The name of the new rule. + :param AutoModTriggerType trigger_type: The trigger type of the new rule. + :param Optional[AutoModTriggerMetadata] trigger_metadata: The trigger metadata payload representation. This can be omitted based on the trigger type. + :param List[AutoModAction] actions: The actions that will execute when the rule is triggered. + :param Optional[bool] enabled: Whether the rule will be enabled upon creation. False by default. + :param Optional[List[int]] exempt_roles: The role IDs that are whitelisted by the rule, if given. The maximum is 20. + :param Optional[List[int]] exempt_channels: The channel IDs that are whitelisted by the rule, if given. The maximum is 20 + :param Optional[str] reason: The reason of the creation :return: The new AutoMod rule :rtype: AutoModerationRule """ @@ -2617,24 +2414,15 @@ async def modify_auto_moderation_rule( """ Edits an AutoMod rule - :param rule: The rule to modify - :type rule: Union[int, Snowflake, AutoModerationRule] - :param name: The name of the new rule. - :type name: str - :param trigger_type: The trigger type of the new rule. - :type trigger_type: AutoModTriggerType - :param trigger_metadata: The trigger metadata payload representation. This can be omitted based on the trigger type. - :type trigger_metadata: Optional[AutoModTriggerMetadata] - :param actions: The actions that will execute when the rule is triggered. - :type actions: List[AutoModAction] - :param enabled: Whether the rule will be enabled upon creation. False by default. - :type enabled: Optional[bool] - :param exempt_roles: The role IDs that are whitelisted by the rule, if given. The maximum is 20. - :type exempt_roles: Optional[List[int]] - :param exempt_channels: The channel IDs that are whitelisted by the rule, if given. The maximum is 20 - :type exempt_channels: Optional[List[int]] - :param reason: The reason of the creation - :type reason: Optional[str] + :param Union[int, Snowflake, AutoModerationRule] rule: The rule to modify + :param str name: The name of the new rule. + :param AutoModTriggerType trigger_type: The trigger type of the new rule. + :param Optional[AutoModTriggerMetadata] trigger_metadata: The trigger metadata payload representation. This can be omitted based on the trigger type. + :param List[AutoModAction] actions: The actions that will execute when the rule is triggered. + :param Optional[bool] enabled: Whether the rule will be enabled upon creation. False by default. + :param Optional[List[int]] exempt_roles: The role IDs that are whitelisted by the rule, if given. The maximum is 20. + :param Optional[List[int]] exempt_channels: The channel IDs that are whitelisted by the rule, if given. The maximum is 20 + :param Optional[str] reason: The reason of the creation :return: The new AutoMod rule :rtype: AutoModerationRule """ @@ -2685,14 +2473,10 @@ async def get_audit_logs( """ Gets the audit logs of the guild. - :param limit?: How many entries to get, default 100 - :type limit?: Optional[int] - :param user_id?: User ID snowflake. filter the log for actions made by a user. - :type user_id?: Optional[Union[User, int, Snowflake]] - :param action_type?: The Type of the audit log action. - :type action_type?: Optional[Union[int, AuditLogEvents]] - :param before?: filter the log before a certain entry id. - :type before?: Union[int, Snowflake] + :param Optional[int] limit: How many entries to get, default 100 + :param Optional[Union[User, int, Snowflake]] user_id: User ID snowflake. filter the log for actions made by a user. + :param Optional[Union[int, AuditLogEvents]] action_type: The Type of the audit log action. + :param Union[int, Snowflake] before: filter the log before a certain entry id. :return: The guild audit logs :rtype: AuditLogs """ @@ -2728,8 +2512,7 @@ async def get_latest_audit_log_action( """ Gets the latest audit log action of either a user or an action type - :param of: The user, user id or action type to look for - :type of: Union[User, Snowflake, AuditLogEvents, int, Tuple[Union[User, Snowflake, int], Union[AuditLogEvents, int]]] + :param Union[User, Snowflake, AuditLogEvents, int, Tuple[Union[User, Snowflake, int], Union[AuditLogEvents, int]]] of: The user, user id or action type to look for :return: The latest AuditLog action that applies to the ``of`` parameter :rtype: AuditLogs """ @@ -2767,10 +2550,8 @@ async def get_full_audit_logs( """ Gets the full audit log of the guild. - :param user_id?: User ID snowflake. filter the log for actions made by a user. - :type user_id?: Optional[Union[User, int, Snowflake]] - :param action_type?: The type of the audit log action. - :type action_type?: Optional[Union[int, AuditLogEvents]] + :param Optional[Union[User, int, Snowflake]] user_id: User ID snowflake. filter the log for actions made by a user. + :param Optional[Union[int, AuditLogEvents]] action_type: The type of the audit log action. :return: The full AuditLog of the guild :rtype: AuditLogs """ @@ -2834,6 +2615,7 @@ async def get_full_audit_logs( def icon_url(self) -> Optional[str]: """ Returns the URL of the guild's icon. + :return: URL of the guild's icon (None will be returned if no icon is set) :rtype: str """ @@ -2848,6 +2630,7 @@ def icon_url(self) -> Optional[str]: def banner_url(self) -> Optional[str]: """ Returns the URL of the guild's banner. + :return: URL of the guild's banner (None will be returned if no banner is set) :rtype: str """ @@ -2862,6 +2645,7 @@ def banner_url(self) -> Optional[str]: def splash_url(self) -> Optional[str]: """ Returns the URL of the guild's invite splash banner. + :return: URL of the guild's invite splash banner (None will be returned if no banner is set) :rtype: str """ @@ -2875,6 +2659,7 @@ def splash_url(self) -> Optional[str]: def discovery_splash_url(self) -> Optional[str]: """ Returns the URL of the guild's discovery splash banner. + :return: URL of the guild's discovery splash banner (None will be returned if no banner is set) :rtype: str """ @@ -2892,14 +2677,14 @@ class GuildPreview(DictSerializerMixin, IDMixin): :ivar Snowflake id: The ID of the guild. :ivar str name: The name of the guild. - :ivar Optional[str] icon?: The icon of the guild. - :ivar Optional[str] splash?: The invite splash banner of the guild. - :ivar Optional[str] discovery_splash?: The discovery splash banner of the guild. + :ivar Optional[str] icon: The icon of the guild. + :ivar Optional[str] splash: The invite splash banner of the guild. + :ivar Optional[str] discovery_splash: The discovery splash banner of the guild. :ivar List[Emoji] emojis: The list of emojis from the guild. :ivar List[GuildFeatures] features: The list of features of the guild. :ivar int approximate_member_count: The approximate amount of members in the guild. :ivar int approximate_presence_count: The approximate amount of presences in the guild. - :ivar Optional[str] description?: The description of the guild. + :ivar Optional[str] description: The description of the guild. """ id: Snowflake = field(converter=Snowflake) @@ -2960,7 +2745,7 @@ class GuildTemplate(DictSerializerMixin): :ivar str code: The code of the guild template. :ivar str name: The name of the guild template. - :ivar Optional[str] description?: The description of the guild template, if given. + :ivar Optional[str] description: The description of the guild template, if given. :ivar int usage_count: The amount of uses on the template. :ivar Snowflake creator_id: User ID of the creator of this template. :ivar User creator: The User object of the creator of this template. @@ -2968,7 +2753,7 @@ class GuildTemplate(DictSerializerMixin): :ivar datetime update_at: The time when this template was updated. :ivar Snowflake source_guild_id: The Guild ID that the template sourced from. :ivar Guild serialized_source_guild: A partial Guild object from the sourced template. - :ivar Optional[bool] is_dirty?: A status that denotes if the changes are unsynced. + :ivar Optional[bool] is_dirty: A status that denotes if the changes are unsynced. """ code: str = field() @@ -3000,24 +2785,20 @@ class ScheduledEvents(DictSerializerMixin, IDMixin): """ A class object representing the scheduled events of a guild. - .. note:: - Some attributes are optional via creator_id/creator implementation by the API: - "`creator_id` will be null and `creator` will not be included for events created before October 25th, 2021, when the concept of `creator_id` was introduced and tracked." - :ivar Snowflake id: The ID of the scheduled event. :ivar Snowflake guild_id: The ID of the guild that this scheduled event belongs to. - :ivar Optional[Snowflake] channel_id?: The channel ID in which the scheduled event belongs to, if any. - :ivar Optional[Snowflake] creator_id?: The ID of the user that created the scheduled event. + :ivar Optional[Snowflake] channel_id: The channel ID in which the scheduled event belongs to, if any. + :ivar Optional[Snowflake] creator_id: The ID of the user that created the scheduled event. :ivar str name: The name of the scheduled event. :ivar str description: The description of the scheduled event. - :ivar datetime scheduled_start_time?: The scheduled event start time. - :ivar Optional[datetime] scheduled_end_time?: The scheduled event end time, if any. + :ivar datetime scheduled_start_time: The scheduled event start time. + :ivar Optional[datetime] scheduled_end_time: The scheduled event end time, if any. :ivar int privacy_level: The privacy level of the scheduled event. :ivar int entity_type: The type of the scheduled event. - :ivar Optional[Snowflake] entity_id?: The ID of the entity associated with the scheduled event. - :ivar Optional[EventMetadata] entity_metadata?: Additional metadata associated with the scheduled event. - :ivar Optional[User] creator?: The user that created the scheduled event. - :ivar Optional[int] user_count?: The number of users subscribed to the scheduled event. + :ivar Optional[Snowflake] entity_id: The ID of the entity associated with the scheduled event. + :ivar Optional[EventMetadata] entity_metadata: Additional metadata associated with the scheduled event. + :ivar Optional[User] creator: The user that created the scheduled event. + :ivar Optional[int] user_count: The number of users subscribed to the scheduled event. :ivar int status: The status of the scheduled event :ivar Optional[str] image: The hash containing the image of an event, if applicable. """ @@ -3099,4 +2880,6 @@ async def delete(self) -> None: @property def url(self) -> str: + """Returns the URL of the invite.""" + return f"https://discord.gg/{self.code}" if self.code else None From a23dbfec49af63c48d095de1293b880e4deaee25 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 11:54:38 +0100 Subject: [PATCH 13/32] update gw.py and move location of Permission class --- interactions/api/models/gw.py | 125 +++++++++++++------------- interactions/api/models/misc.py | 6 +- interactions/client/models/command.py | 31 +------ interactions/client/models/misc.py | 27 +----- 4 files changed, 68 insertions(+), 121 deletions(-) diff --git a/interactions/api/models/gw.py b/interactions/api/models/gw.py index 52eb94f89..6aae9c9c0 100644 --- a/interactions/api/models/gw.py +++ b/interactions/api/models/gw.py @@ -8,6 +8,7 @@ define, field, ) +from ...client.enums import PermissionType from .channel import Channel, ThreadMember from .emoji import Emoji from .guild import EventMetadata @@ -29,6 +30,7 @@ __all__ = ( "AutoModerationAction", "AutoModerationRule", + "ApplicationCommandPermission", "ApplicationCommandPermissions", "EmbeddedActivity", "Integration", @@ -88,18 +90,15 @@ class AutoModerationRule(DictSerializerMixin, IDMixin): A class object representing the gateway events ``AUTO_MODERATION_RULE_CREATE``, ``AUTO_MODERATION_RULE_UPDATE``, and ``AUTO_MODERATION_RULE_DELETE`` .. note:: - This is undocumented by the Discord API, so these attribute docs may or may not be finalised. - - .. note:: - ``event_type`` at the moment is only ``1``, which represents message sending. + ``event_type`` at the moment can only be ``1``, which represents message sending. :ivar Snowflake id: The ID of the rule. :ivar Snowflake guild_id: The guild ID associated with the rule. :ivar str name: The rule name. :ivar Snowflake creator_id: The user ID that first created this rule. :ivar int event_type: The rule type in which automod checks. - :ivar int trigger_type: The automod type. It characterises what type of information that is checked. - :ivar Dict[str, List[str]] trigger_metadata: Additional data needed to figure out whether this rule should be triggered. + :ivar AutoModTriggerType trigger_type: The automod type. It characterises what type of information that is checked. + :ivar AutoModTriggerMetadata trigger_metadata: Additional data needed to figure out whether this rule should be triggered. :ivar List[AutoModerationAction] actions: The actions that will be executed when the rule is triggered. :ivar bool enabled: Whether the rule is enabled. :ivar List[Snowflake] exempt_roles: The role IDs that should not be affected by this rule. (Max 20) @@ -119,26 +118,49 @@ class AutoModerationRule(DictSerializerMixin, IDMixin): exempt_channels: List[Snowflake] = field(converter=convert_list(Snowflake)) +@define() +class ApplicationCommandPermission(DictSerializerMixin): + """ + A class object representing the permission of an application command. + + The structure for a permission: + + .. code-block:: python + + interactions.Permission( + id=1234567890, + type=interactions.PermissionType.USER, + permission=True, + ) + + :ivar int id: The ID of the permission. + :ivar PermissionType type: The type of permission. + :ivar bool permission: The permission state. ``True`` for allow, ``False`` for disallow. + """ + + id: int = field() + type: PermissionType = field(converter=PermissionType) + permission: bool = field() + + def __attrs_post_init__(self): + self._json["type"] = self.type.value + + @define() class ApplicationCommandPermissions(ClientSerializerMixin, IDMixin): """ A class object representing the gateway event ``APPLICATION_COMMAND_PERMISSIONS_UPDATE``. - .. note:: This is undocumented by the Discord API, so these attribute docs may or may not be finalised. - - :ivar Snowflake application_id: The application ID associated with the event. - :ivar Snowflake guild_id: The guild ID associated with the event. - :ivar Snowflake id: The ID of the command associated with the event. (?) - :ivar List[Permission] permissions: The updated permissions of the associated command/event. + :ivar Snowflake id: ID of the command or the application ID + :ivar Snowflake application_id: ID of the application the command belongs to + :ivar Snowflake guild_id: ID of the guild + :ivar List[ApplicationCommandPermission] permissions: Permissions for the command in the guild, max of 100 """ application_id: Snowflake = field(converter=Snowflake) guild_id: Snowflake = field(converter=Snowflake) id: Snowflake = field(converter=Snowflake) - # from ...client.models.command import Permission - - # permissions: List[Permission] = field(converter=convert_list(Permission)) - permissions = field() + permissions: List[ApplicationCommandPermission] = field(converter=convert_list(ApplicationCommandPermission)) @define() @@ -242,15 +264,15 @@ class GuildMember(Member): :ivar Snowflake guild_id: The guild ID. :ivar User user: The user of the guild. :ivar str nick: The nickname of the member. - :ivar Optional[str] avatar?: The hash containing the user's guild avatar, if applicable. + :ivar Optional[str] avatar: The hash containing the user's guild avatar, if applicable. :ivar List[int] roles: The list of roles of the member. :ivar datetime joined_at: The timestamp the member joined the guild at. :ivar datetime premium_since: The timestamp the member has been a server booster since. :ivar bool deaf: Whether the member is deafened. :ivar bool mute: Whether the member is muted. - :ivar Optional[bool] pending?: Whether the member is pending to pass membership screening. - :ivar Optional[Permissions] permissions?: Whether the member has permissions. - :ivar Optional[str] communication_disabled_until?: How long until they're unmuted, if any. + :ivar Optional[bool] pending: Whether the member is pending to pass membership screening. + :ivar Optional[Permissions] permissions: Whether the member has permissions. + :ivar Optional[str] communication_disabled_until: How long until they're unmuted, if any. """ _guild_id: Snowflake = field(converter=Snowflake, discord_name="guild_id") @@ -317,22 +339,22 @@ class GuildScheduledEvent(ClientSerializerMixin, IDMixin): .. note:: Some attributes are optional via creator_id/creator implementation by the API: - "`creator_id` will be null and `creator` will not be included for events created before October 25th, 2021, when the concept of `creator_id` was introduced and tracked." + "``creator_id`` will be null and ``creator`` will not be included for events created before October 25th, 2021, when the concept of ``creator_id`` was introduced and tracked." :ivar Snowflake id: The ID of the scheduled event. :ivar Snowflake guild_id: The ID of the guild that this scheduled event belongs to. - :ivar Optional[Snowflake] channel_id?: The channel ID in which the scheduled event belongs to, if any. - :ivar Optional[Snowflake] creator_id?: The ID of the user that created the scheduled event. + :ivar Optional[Snowflake] channel_id: The channel ID in which the scheduled event belongs to, if any. + :ivar Optional[Snowflake] creator_id: The ID of the user that created the scheduled event. :ivar str name: The name of the scheduled event. :ivar str description: The description of the scheduled event. - :ivar datetime scheduled_start_time?: The scheduled event start time. - :ivar Optional[datetime] scheduled_end_time?: The scheduled event end time, if any. + :ivar datetime scheduled_start_time: The scheduled event start time. + :ivar Optional[datetime] scheduled_end_time: The scheduled event end time, if any. :ivar int privacy_level: The privacy level of the scheduled event. :ivar int entity_type: The type of the scheduled event. - :ivar Optional[Snowflake] entity_id?: The ID of the entity associated with the scheduled event. - :ivar Optional[EventMetadata] entity_metadata?: Additional metadata associated with the scheduled event. - :ivar Optional[User] creator?: The user that created the scheduled event. - :ivar Optional[int] user_count?: The number of users subscribed to the scheduled event. + :ivar Optional[Snowflake] entity_id: The ID of the entity associated with the scheduled event. + :ivar Optional[EventMetadata] entity_metadata: Additional metadata associated with the scheduled event. + :ivar Optional[User] creator: The user that created the scheduled event. + :ivar Optional[int] user_count: The number of users subscribed to the scheduled event. :ivar int status: The status of the scheduled event :ivar Optional[str] image: The hash containing the image of an event, if applicable. """ @@ -376,9 +398,7 @@ class Integration(DictSerializerMixin, IDMixin): A class object representing the gateway events ``INTEGRATION_CREATE``, ``INTEGRATION_UPDATE`` and ``INTEGRATION_DELETE``. .. note:: - The documentation of this event is the same as :class:`interactions.api.models.guild.Guild`. - The only key missing attribute is ``guild_id``. Likewise, the documentation - below reflects this. + The documentation of this event is the same as :class:`.Guild`. :ivar Snowflake id: The ID of the event. :ivar str name: The name of the event. @@ -398,29 +418,6 @@ class Integration(DictSerializerMixin, IDMixin): :ivar Snowflake guild_id: The guild ID of the event. """ - # __slots__ = ( - # "_json", - # "id", - # "name", - # "type", - # "enabled", - # "syncing", - # "role_id", - # "enable_emoticons", - # "expire_behavior", - # "expire_grace_period", - # "user", - # "account", - # "synced_at", - # "subscriber_count", - # "revoked", - # "application", - # "guild_id", - # # TODO: Document these when Discord does. - # "guild_hashes", - # "application_id", - # ) - id: Snowflake = field(converter=Snowflake) name: str = field() type: str = field() @@ -465,7 +462,7 @@ class MessageDelete(DictSerializerMixin): :ivar List[Snowflake] ids: The message IDs of the event. :ivar Snowflake channel_id: The channel ID of the event. - :ivar Optional[Snowflake] guild_id?: The guild ID of the event. + :ivar Optional[Snowflake] guild_id: The guild ID of the event. """ ids: List[Snowflake] = field(converter=convert_list(Snowflake)) @@ -478,12 +475,12 @@ class MessageReaction(ClientSerializerMixin): """ A class object representing the gateway event ``MESSAGE_REACTION_ADD`` and ``MESSAGE_REACTION_REMOVE``. - :ivar Optional[Snowflake] user_id?: The user ID of the event. + :ivar Optional[Snowflake] user_id: The user ID of the event. :ivar Snowflake channel_id: The channel ID of the event. :ivar Snowflake message_id: The message ID of the event. - :ivar Optional[Snowflake] guild_id?: The guild ID of the event. - :ivar Optional[Member] member?: The member of the event. - :ivar Optional[Emoji] emoji?: The emoji of the event. + :ivar Optional[Snowflake] guild_id: The guild ID of the event. + :ivar Optional[Member] member: The member of the event. + :ivar Optional[Emoji] emoji: The emoji of the event. """ user_id: Optional[Snowflake] = field(converter=Snowflake, default=None) @@ -504,7 +501,7 @@ class MessageReactionRemove(MessageReaction): A class object representing the gateway events ``MESSAGE_REACTION_REMOVE_ALL`` and ``MESSAGE_REACTION_REMOVE_EMOJI``. .. note:: - This class inherits the already existing attributes of :class:`interactions.api.models.gw.Reaction`. + This class inherits the already existing attributes of :class:`.MessageReaction`. The main missing attribute is ``member``. :ivar Optional[Snowflake] user_id?: The user ID of the event. @@ -527,7 +524,7 @@ class ThreadList(DictSerializerMixin): A class object representing the gateway event ``THREAD_LIST_SYNC``. :ivar Snowflake guild_id: The guild ID of the event. - :ivar Optional[List[Snowflake]] channel_ids?: The channel IDs of the event. + :ivar Optional[List[Snowflake]] channel_ids: The channel IDs of the event. :ivar List[Channel] threads: The threads of the event. :ivar List[ThreadMember] members: The members of the thread of the event. """ @@ -546,8 +543,8 @@ class ThreadMembers(DictSerializerMixin, IDMixin): :ivar Snowflake id: The ID of the event. :ivar Snowflake guild_id: The guild ID of the event. :ivar int member_count: The member count of the event. - :ivar Optional[List[ThreadMember]] added_members?: The added members of the thread of the event. - :ivar Optional[List[Snowflake]] removed_member_ids?: The removed IDs of members of the thread of the event. + :ivar Optional[List[ThreadMember]] added_members: The added members of the thread of the event. + :ivar Optional[List[Snowflake]] removed_member_ids: The removed IDs of members of the thread of the event. """ id: Snowflake = field(converter=Snowflake) diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index b0e19d173..8a55c934d 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -245,10 +245,14 @@ class AutoModTriggerMetadata(DictSerializerMixin): :ivar Optional[List[str]] keyword_filter: Words to match against content. :ivar Optional[List[str]] presets: The internally pre-defined wordsets which will be searched for in content. + :ivar Optional[List[str]] allow_list: Substrings which will be exempt from triggering the preset trigger type + :ivar Optional[int] mention_total_limit: Total number of unique role and user mentions allowed per message (Maximum of 50) """ keyword_filter: Optional[List[str]] = field(default=None) - presets: Optional[List[str]] = field(default=None) + presets: Optional[List[AutoModKeywordPresetTypes]] = field(converter=convert_list(AutoModKeywordPresetTypes)) + allow_list: Optional[List[str]] = field(default=None) + mention_total_limit: Optional[int] = field(default=None) class Color: diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index 44cbcfea2..ff95c8625 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -13,7 +13,7 @@ from ...api.models.user import User from ...utils.attrs_utils import DictSerializerMixin, convert_list, define, field from ...utils.missing import MISSING -from ..enums import ApplicationCommandType, Locale, OptionType, PermissionType +from ..enums import ApplicationCommandType, Locale, OptionType if TYPE_CHECKING: from ...api.dispatch import Listener @@ -23,7 +23,6 @@ __all__ = ( "Choice", "Option", - "Permission", "ApplicationCommand", "option", "StopCommand", @@ -155,34 +154,6 @@ def __attrs_post_init__(self): self._json["choices"] = [choice._json for choice in self.choices] -@define() -class Permission(DictSerializerMixin): - """ - A class object representing the permission of an application command. - - The structure for a permission: - - .. code-block:: python - - interactions.Permission( - id=1234567890, - type=interactions.PermissionType.USER, - permission=True, - ) - - :ivar int id: The ID of the permission. - :ivar PermissionType type: The type of permission. - :ivar bool permission: The permission state. ``True`` for allow, ``False`` for disallow. - """ - - id: int = field() - type: PermissionType = field(converter=PermissionType) - permission: bool = field() - - def __attrs_post_init__(self): - self._json["type"] = self.type.value - - @define() class ApplicationCommand(DictSerializerMixin): """ diff --git a/interactions/client/models/misc.py b/interactions/client/models/misc.py index 2800120bd..6bff71fb0 100644 --- a/interactions/client/models/misc.py +++ b/interactions/client/models/misc.py @@ -7,7 +7,7 @@ from ...api.models.role import Role from ...api.models.user import User from ...utils.attrs_utils import DictSerializerMixin, convert_dict, convert_list, define, field -from ..enums import ApplicationCommandType, ComponentType, InteractionType, PermissionType +from ..enums import ApplicationCommandType, ComponentType, InteractionType from ..models.command import Option from .component import ActionRow @@ -107,28 +107,3 @@ def __attrs_post_init__(self): if self.member: if self.guild_id: self.member._extras["guild_id"] = self.guild_id - - -@define() -class Permission(DictSerializerMixin): - """ - A class object representing the permission of an application command. - - The structure for a permission: - - .. code-block:: python - - interactions.Permission( - id=1234567890, - type=interactions.PermissionType.USER, - permission=True, - ) - - :ivar int id: The ID of the permission. - :ivar PermissionType type: The type of permission. - :ivar bool permission: The permission state. ``True`` for allow, ``False`` for disallow. - """ - - id: int = field() - type: PermissionType = field(converter=PermissionType) - permission: bool = field() From fc4e518f80b838150ed484c0ce63184ee33bc57c Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 18:11:12 +0100 Subject: [PATCH 14/32] update member.py --- interactions/api/models/member.py | 118 +++++++++++------------------- 1 file changed, 42 insertions(+), 76 deletions(-) diff --git a/interactions/api/models/member.py b/interactions/api/models/member.py index 61436969b..325451770 100644 --- a/interactions/api/models/member.py +++ b/interactions/api/models/member.py @@ -31,15 +31,15 @@ class Member(ClientSerializerMixin, IDMixin): :ivar User user: The user of the guild. :ivar str nick: The nickname of the member. - :ivar Optional[str] avatar?: The hash containing the user's guild avatar, if applicable. + :ivar Optional[str] avatar: The hash containing the user's guild avatar, if applicable. :ivar List[int] roles: The list of roles of the member. :ivar datetime joined_at: The timestamp the member joined the guild at. :ivar datetime premium_since: The timestamp the member has been a server booster since. :ivar bool deaf: Whether the member is deafened. :ivar bool mute: Whether the member is muted. - :ivar Optional[bool] pending?: Whether the member is pending to pass membership screening. - :ivar Optional[Permissions] permissions?: Whether the member has permissions. - :ivar Optional[str] communication_disabled_until?: How long until they're unmuted, if any. + :ivar Optional[bool] pending: Whether the member is pending to pass membership screening. + :ivar Optional[Permissions] permissions: Whether the member has permissions. + :ivar Optional[str] communication_disabled_until: How long until they're unmuted, if any. """ user: Optional[User] = field(converter=User, default=None, add_client=True) @@ -80,6 +80,7 @@ def guild_id(self) -> Optional[Union[Snowflake, LibraryException]]: """ Attempts to get the guild ID the member is in. Only works then roles or nick or joined at is present. + :return: The ID of the guild this member belongs to. """ @@ -130,6 +131,7 @@ def check(_member: Member): @property def avatar(self) -> Optional[str]: + """Returns the user's avatar hash, if any.""" return self._avatar or getattr(self.user, "avatar", None) @property @@ -174,18 +176,12 @@ async def ban( """ Bans the member from a guild. - :param guild_id: The id of the guild to ban the member from - :type guild_id: Optional[Union[int, Snowflake, "Guild"]] - :param seconds?: Number of seconds to delete messages, from 0 to 604800. Defaults to 0 - :type seconds?: Optional[int] - :param minutes?: Number of minutes to delete messages, from 0 to 10080 - :type minutes?: Optional[int] - :param hours?: Number of hours to delete messages, from 0 to 168 - :type hours?: Optional[int] - :param days?: Number of days to delete messages, from 0 to 7 - :type days?: Optional[int] - :param reason?: The reason of the ban - :type reason?: Optional[str] + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild to ban the member from + :param Optional[int] seconds: Number of seconds to delete messages, from 0 to 604800. Defaults to 0 + :param Optional[int] minutes: Number of minutes to delete messages, from 0 to 10080 + :param Optional[int] hours: Number of hours to delete messages, from 0 to 168 + :param Optional[int] days: Number of days to delete messages, from 0 to 7 + :param Optional[str] reason: The reason of the ban """ if guild_id is MISSING: @@ -226,10 +222,8 @@ async def kick( """ Kicks the member from a guild. - :param guild_id: The id of the guild to kick the member from - :type guild_id: Optional[Union[int, Snowflake, "Guild"]] - :param reason?: The reason for the kick - :type reason?: Optional[str] + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild to kick the member from + :param Optional[str] reason: The reason for the kick """ if not self._client: raise LibraryException(code=13) @@ -260,12 +254,9 @@ async def add_role( """ This method adds a role to a member. - :param role: The role to add. Either ``Role`` object or role_id - :type role: Union[Role, int, Snowflake] - :param guild_id: The id of the guild to add the roles to the member - :type guild_id: Optional[Union[int, Snowflake, "Guild"]] - :param reason?: The reason why the roles are added - :type reason?: Optional[str] + :param Union[Role, int, Snowflake] role: The role to add. Either ``Role`` object or role_id + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild to add the roles to the member + :param Optional[str] reason: The reason why the roles are added """ if not self._client: raise LibraryException(code=13) @@ -297,12 +288,9 @@ async def remove_role( """ This method removes a role from a member. - :param role: The role to remove. Either ``Role`` object or role_id - :type role: Union[Role, int] - :param guild_id: The id of the guild to remove the roles of the member - :type guild_id: Optional[Union[int, Snowflake, "Guild"]] - :param reason?: The reason why the roles are removed - :type reason?: Optional[str] + :param Union[Role, int] role: The role to remove. Either ``Role`` object or role_id + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild to remove the roles of the member + :param Optional[str] reason: The reason why the roles are removed """ if not self._client: raise LibraryException(code=13) @@ -348,20 +336,13 @@ async def send( """ Sends a DM to the member. - :param content?: The contents of the message as a string or string-converted value. - :type content?: Optional[str] - :param components?: A component, or list of components for the message. - :type components?: Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] - :param tts?: Whether the message utilizes the text-to-speech Discord programme or not. - :type tts?: Optional[bool] - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param files?: A file or list of files to be attached to the message. - :type files?: Optional[Union[File, List[File]]] - :param embeds?: An embed, or list of embeds for the message. - :type embeds?: Optional[Union[Embed, List[Embed]]] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] + :param Optional[str] content: The contents of the message as a string or string-converted value. + :param Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] components: A component, or list of components for the message. + :param Optional[bool] tts: Whether the message utilizes the text-to-speech Discord programme or not. + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Optional[Union[File, List[File]]] files: A file or list of files to be attached to the message. + :param Optional[Union[Embed, List[Embed]]] embeds: An embed, or list of embeds for the message. + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. :return: The sent message as an object. :rtype: Message """ @@ -429,22 +410,14 @@ async def modify( """ Modifies the member of a guild. - :param guild_id: The id of the guild to modify the member on - :type guild_id: Optional[Union[int, Snowflake, "Guild"]] - :param nick?: The nickname of the member - :type nick?: Optional[str] - :param roles?: A list of all role ids the member has - :type roles?: Optional[List[int]] - :param mute?: whether the user is muted in voice channels - :type mute?: Optional[bool] - :param deaf?: whether the user is deafened in voice channels - :type deaf?: Optional[bool] - :param channel_id?: id of channel to move user to (if they are connected to voice) - :type channel_id?: Optional[Union[Channel, int, Snowflake]] - :param communication_disabled_until?: when the user's timeout will expire and the user will be able to communicate in the guild again (up to 28 days in the future) - :type communication_disabled_until?: Optional[datetime.isoformat] - :param reason?: The reason of the modifying - :type reason?: Optional[str] + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild to modify the member on + :param Optional[str] nick: The nickname of the member + :param Optional[List[int]] roles: A list of all role ids the member has + :param Optional[bool] mute: whether the user is muted in voice channels + :param Optional[bool] deaf: whether the user is deafened in voice channels + :param Optional[Union[Channel, int, Snowflake]] channel_id: id of channel to move user to (if they are connected to voice) + :param Optional[datetime.isoformat] communication_disabled_until: when the user's timeout will expire and the user will be able to communicate in the guild again (up to 28 days in the future) + :param Optional[str] reason: The reason of the modifying :return: The modified member object :rtype: Member """ @@ -499,8 +472,7 @@ async def add_to_thread( """ Adds the member to a thread. - :param thread_id: The id of the thread to add the member to - :type thread_id: Union[int, Snowflake, Channel] + :param Union[int, Snowflake, Channel] thread_id: The id of the thread to add the member to """ if not self._client: raise LibraryException(code=13) @@ -518,8 +490,7 @@ def get_avatar_url( """ Returns the URL of the member's avatar for the specified guild. - :param guild_id: The id of the guild to get the member's avatar from - :type guild_id: Optional[Union[int, Snowflake, "Guild"]] + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild to get the member's avatar from :return: URL of the members's avatar (None will be returned if no avatar is set) :rtype: str """ @@ -551,8 +522,7 @@ async def get_guild_permissions( user overwrites that can be assigned to channels or categories. If you need these overwrites, look into :meth:`.Channel.get_permissions_for`. - :param guild: The guild of the member - :type guild: Guild + :param Guild guild: The guild of the member :return: Base permissions of the member in the specified guild :rtype: Permissions """ @@ -597,14 +567,10 @@ async def has_permissions( If the channel argument is present, the function will look if the member has the permissions in the specified channel. If the argument is missing, then it will only consider the member's guild permissions. - :param \*permissions: The list of permissions - :type \*permissions: Union[int, Permissions] - :param channel: The channel where to check for permissions - :type channel: Channel - :param guild_id: The id of the guild - :type guild_id: Optional[Union[int, Snowflake, Guild]] - :param operator: The operator to use to calculate permissions. Possible values: `and`, `or`. Defaults to `and`. - :type operator: str + :param Union[int, Permissions] \*permissions: The list of permissions + :param Channel channel: The channel where to check for permissions + :param Optional[Union[int, Snowflake, Guild]] guild_id: The id of the guild + :param Optional[str] operator: The operator to use to calculate permissions. Possible values: `and`, `or`. Defaults to `and`. :return: Whether the member has the permissions :rtype: bool """ From 6c00acee47b6367843aa3a4910afe2add7f7746a Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 18:11:19 +0100 Subject: [PATCH 15/32] update message.py --- interactions/api/models/message.py | 122 +++++++++++------------------ 1 file changed, 46 insertions(+), 76 deletions(-) diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index aa7611022..efe0cdd15 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -749,34 +749,34 @@ class Message(ClientSerializerMixin, IDMixin): :ivar Snowflake id: ID of the message. :ivar Snowflake channel_id: ID of the channel the message was sent in - :ivar Optional[Snowflake] guild_id?: ID of the guild the message was sent in, if it exists. + :ivar Optional[Snowflake] guild_id: ID of the guild the message was sent in, if it exists. :ivar User author: The author of the message. - :ivar Optional[Member] member?: The member object associated with the author, if any. + :ivar Optional[Member] member: The member object associated with the author, if any. :ivar str content: Message contents. :ivar datetime timestamp: Timestamp denoting when the message was sent. - :ivar Optional[datetime] edited_timestamp?: Timestamp denoting when the message was edited, if any. + :ivar Optional[datetime] edited_timestamp: Timestamp denoting when the message was edited, if any. :ivar bool tts: Status dictating if this was a TTS message or not. :ivar bool mention_everyone: Status dictating of this message mentions everyone - :ivar Optional[List[Union[Member, User]]] mentions?: Array of user objects with an additional partial member field. - :ivar Optional[List[str]] mention_roles?: Array of roles mentioned in this message - :ivar Optional[List[ChannelMention]] mention_channels?: Channels mentioned in this message, if any. + :ivar Optional[List[Union[Member, User]]] mentions: Array of user objects with an additional partial member field. + :ivar Optional[List[str]] mention_roles: Array of roles mentioned in this message + :ivar Optional[List[ChannelMention]] mention_channels: Channels mentioned in this message, if any. :ivar List[Attachment] attachments: An array of attachments :ivar List[Embed] embeds: An array of embeds - :ivar Optional[List[ReactionObject]] reactions?: Reactions to the message. + :ivar Optional[List[ReactionObject]] reactions: Reactions to the message. :ivar Union[int, str] nonce: Used for message validation :ivar bool pinned: Whether this message is pinned. - :ivar Optional[Snowflake] webhook_id?: Webhook ID if the message is generated by a webhook. + :ivar Optional[Snowflake] webhook_id: Webhook ID if the message is generated by a webhook. :ivar MessageType type: Type of message - :ivar Optional[MessageActivity] activity?: Message activity object that's sent by Rich Presence - :ivar Optional[Application] application?: Application object that's sent by Rich Presence - :ivar Optional[MessageReference] message_reference?: Data showing the source of a message (crosspost, channel follow, add, pin, or replied message) + :ivar Optional[MessageActivity] activity: Message activity object that's sent by Rich Presence + :ivar Optional[Application] application: Application object that's sent by Rich Presence + :ivar Optional[MessageReference] message_reference: Data showing the source of a message (crosspost, channel follow, add, pin, or replied message) :ivar int flags: Message flags - :ivar Optional[MessageInteraction] interaction?: Message interaction object, if the message is sent by an interaction. - :ivar Optional[Channel] thread?: The thread that started from this message, if any, with a thread member object embedded. - :ivar Optional[List[ActionRow]] components?: Array of Action Rows associated with this message, if any. - :ivar Optional[List[PartialSticker]] sticker_items?: An array of message sticker item objects, if sent with them. - :ivar Optional[List[Sticker]] stickers?: Array of sticker objects sent with the message if any. Deprecated. - :ivar Optional[int] position?: The approximate position of the message in a thread. + :ivar Optional[MessageInteraction] interaction: Message interaction object, if the message is sent by an interaction. + :ivar Optional[Channel] thread: The thread that started from this message, if any, with a thread member object embedded. + :ivar Optional[List[ActionRow]] components: Array of Action Rows associated with this message, if any. + :ivar Optional[List[PartialSticker]] sticker_items: An array of message sticker item objects, if sent with them. + :ivar Optional[List[Sticker]] stickers: Array of sticker objects sent with the message if any. Deprecated. + :ivar Optional[int] position: The approximate position of the message in a thread. """ id: Snowflake = field(converter=Snowflake) @@ -859,8 +859,7 @@ async def delete(self, reason: Optional[str] = None) -> None: """ Deletes the message. - :param reason: Optional reason to show up in the audit log. Defaults to `None`. - :type reason: Optional[str] + :param Optional[str] reason: Optional reason to show up in the audit log. Defaults to `None`. """ if not self._client: raise LibraryException(code=13) @@ -893,22 +892,14 @@ async def edit( """ This method edits a message. Only available for messages sent by the bot. - :param content?: The contents of the message as a string or string-converted value. - :type content?: Optional[str] - :param tts?: Whether the message utilizes the text-to-speech Discord programme or not. - :type tts?: Optional[bool] - :param files?: A file or list of files to be attached to the message. - :type files?: Optional[Union[File, List[File]]] - :param embeds?: An embed, or list of embeds for the message. - :type embeds?: Optional[Union[Embed, List[Embed]]] - :param suppress_embeds?: Whether to suppress embeds in the message. - :type suppress_embeds?: Optional[bool] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param components?: A component, or list of components for the message. If `[]` the components will be removed - :type components?: Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] + :param Optional[str] content: The contents of the message as a string or string-converted value. + :param Optional[bool] tts: Whether the message utilizes the text-to-speech Discord programme or not. + :param Optional[Union[File, List[File]]] files: A file or list of files to be attached to the message. + :param Optional[Union[Embed, List[Embed]]] embeds: An embed, or list of embeds for the message. + :param Optional[bool] suppress_embeds: Whether to suppress embeds in the message. + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] components: A component, or list of components for the message. If `[]` the components will be removed :return: The edited message as an object. :rtype: Message """ @@ -1013,22 +1004,14 @@ async def reply( """ Sends a new message replying to the old. - :param content?: The contents of the message as a string or string-converted value. - :type content?: Optional[str] - :param tts?: Whether the message utilizes the text-to-speech Discord programme or not. - :type tts?: Optional[bool] - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param files?: A file or list of files to be attached to the message. - :type files?: Optional[Union[File, List[File]]] - :param embeds?: An embed, or list of embeds for the message. - :type embeds?: Optional[Union[Embed, List[Embed]]] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] - :param components?: A component, or list of components for the message. - :type components?: Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] - :param stickers?: A list of stickers to send with your message. You can send up to 3 stickers per message. - :type stickers?: Optional[List[Sticker]] + :param Optional[str] content: The contents of the message as a string or string-converted value. + :param Optional[bool] tts: Whether the message utilizes the text-to-speech Discord programme or not. + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Optional[Union[File, List[File]]] files: A file or list of files to be attached to the message. + :param Optional[Union[Embed, List[Embed]]] embeds: An embed, or list of embeds for the message. + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. + :param Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] components: A component, or list of components for the message. + :param Optional[List[Sticker]] stickers: A list of stickers to send with your message. You can send up to 3 stickers per message. :return: The sent message as an object. :rtype: Message """ @@ -1128,15 +1111,10 @@ async def create_thread( """ Creates a thread from the message. - :param name: The name of the thread - :type name: str - :param auto_archive_duration?: duration in minutes to automatically archive the thread after recent activity, - can be set to: 60, 1440, 4320, 10080 - :type auto_archive_duration?: Optional[int] - :param invitable?: Boolean to display if the Thread is open to join or private. - :type invitable?: Optional[bool] - :param reason?: An optional reason for the audit log - :type reason?: Optional[str] + :param str name: The name of the thread + :param Optional[int] auto_archive_duration: duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 + :param Optional[bool] invitable: Boolean to display if the Thread is open to join or private. + :param Optional[str] reason: An optional reason for the audit log :return: The created thread :rtype: Channel """ @@ -1161,8 +1139,7 @@ async def create_reaction( """ Adds a reaction to the message. - :param emoji: The Emoji as object or formatted as `name:id` - :type emoji: Union[str, Emoji] + :param Union[str, Emoji] emoji: The Emoji as object or formatted as `name:id` """ if not self._client: raise LibraryException(code=13) @@ -1195,8 +1172,7 @@ async def remove_all_reactions_of( """ Removes all reactions of one emoji of the message. - :param emoji: The Emoji as object or formatted as `name:id` - :type emoji: Union[str, Emoji] + :param Union[str, Emoji] emoji: The Emoji as object or formatted as `name:id` """ if not self._client: raise LibraryException(code=13) @@ -1218,8 +1194,7 @@ async def remove_own_reaction_of( """ Removes the own reaction of an emoji of the message. - :param emoji: The Emoji as object or formatted as `name:id` - :type emoji: Union[str, Emoji] + :param Union[str, Emoji] emoji: The Emoji as object or formatted as `name:id` """ if not self._client: raise LibraryException(code=13) @@ -1240,10 +1215,8 @@ async def remove_reaction_from( """ Removes another reaction of an emoji of the message. - :param emoji: The Emoji as object or formatted as `name:id` - :type emoji: Union[str, Emoji] - :param user: The user or user_id to remove the reaction of - :type user: Union[Member, user, int] + :param Union[str, Emoji] emoji: The Emoji as object or formatted as `name:id` + :param Union[Member, user, int] user: The user or user_id to remove the reaction of """ _emoji = ( (f":{emoji.name.replace(':', '')}:{emoji.id or ''}" if emoji.id else emoji.name) @@ -1268,8 +1241,7 @@ async def get_users_from_reaction( """ Retrieves all users that reacted to the message with the given emoji - :param emoji: The Emoji as object or formatted as `name:id` - :type emoji: Union[str, Emoji] + :param Union[str, Emoji] emoji: The Emoji as object or formatted as `name:id` :return: A list of user objects :rtype: List[User] """ @@ -1308,10 +1280,8 @@ async def get_from_url(cls, url: str, client: "HTTPClient") -> "Message": """ Gets a Message based from its url. - :param url: The full url of the message - :type url: str - :param client: The HTTPClient of your bot. Set ` _client=botvar._http`` - :type client: HTTPClient + :param str url: The full url of the message + :param HTTPClient client: The HTTPClient of your bot. Set ``client=bot._http`` :return: The message the URL points to :rtype: Message """ From fc7249c10aa076efe65495153ff6083cd956b856 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 18:29:40 +0100 Subject: [PATCH 16/32] update message.py --- interactions/api/models/message.py | 177 ++++++++++++----------------- 1 file changed, 73 insertions(+), 104 deletions(-) diff --git a/interactions/api/models/message.py b/interactions/api/models/message.py index efe0cdd15..3e31677f6 100644 --- a/interactions/api/models/message.py +++ b/interactions/api/models/message.py @@ -87,7 +87,7 @@ class MessageActivity(DictSerializerMixin): i.e. : Phasmophobia and Call of Duty. :ivar str type: The message activity type. - :ivar Optional[Snowflake] party_id?: The party ID of the activity. + :ivar Optional[Snowflake] party_id: The party ID of the activity. """ type: int = field() @@ -103,10 +103,10 @@ class MessageReference(DictSerializerMixin): All of the attributes in this class are optionals because a message can potentially never be referenced. - :ivar Optional[Snowflake] message_id?: The ID of the referenced message. - :ivar Optional[Snowflake] channel_id?: The channel ID of the referenced message. - :ivar Optional[Snowflake] guild_id?: The guild ID of the referenced message. - :ivar Optional[bool] fail_if_not_exists?: Whether the message reference exists. + :ivar Optional[Snowflake] message_id: The ID of the referenced message. + :ivar Optional[Snowflake] channel_id: The channel ID of the referenced message. + :ivar Optional[Snowflake] guild_id: The guild ID of the referenced message. + :ivar Optional[bool] fail_if_not_exists: Whether the message reference exists. """ message_id: Optional[Snowflake] = field(converter=Snowflake, default=None) @@ -125,18 +125,18 @@ class Attachment(ClientSerializerMixin, IDMixin): which requires it to be a media file with viewabiltity as a photo, animated photo, GIF and/or video. - If `ephemeral` is given, the attachments will automatically be removed after a set period of time. + If ``ephemeral`` is given, the attachments will automatically be removed after a set period of time. In the case of regular messages, they're available as long as the message associated with the attachment exists. :ivar int id: The ID of the attachment. :ivar str filename: The name of the attachment file. - :ivar Optional[str] description?: The description of the file. - :ivar Optional[str] content_type?: The type of attachment file. + :ivar Optional[str] description: The description of the file. + :ivar Optional[str] content_type: The type of attachment file. :ivar int size: The size of the attachment file. :ivar str url: The CDN URL of the attachment file. :ivar str proxy_url: The proxied/cached CDN URL of the attachment file. - :ivar Optional[int] height?: The height of the attachment file. - :ivar Optional[int] width?: The width of the attachment file. + :ivar Optional[int] height: The height of the attachment file. + :ivar Optional[int] width: The width of the attachment file. :ivar Optional[bool] ephemeral: Whether the attachment is ephemeral. """ @@ -220,9 +220,9 @@ class EmbedImageStruct(DictSerializerMixin): ) :ivar str url: Source URL of the object. - :ivar Optional[str] proxy_url?: Proxied url of the object. - :ivar Optional[int] height?: Height of the object. - :ivar Optional[int] width?: Width of the object. + :ivar Optional[str] proxy_url: Proxied url of the object. + :ivar Optional[int] height: Height of the object. + :ivar Optional[int] width: Width of the object. """ url: str = field() @@ -247,8 +247,8 @@ class EmbedProvider(DictSerializerMixin): """ A class object representing the provider of an embed. - :ivar Optional[str] name?: Name of provider - :ivar Optional[str] url?: URL of provider + :ivar Optional[str] name: Name of provider + :ivar Optional[str] url: URL of provider """ name: Optional[str] = field(default=None) @@ -280,9 +280,9 @@ class EmbedAuthor(DictSerializerMixin): ) :ivar str name: Name of author - :ivar Optional[str] url?: URL of author - :ivar Optional[str] icon_url?: URL of author icon - :ivar Optional[str] proxy_icon_url?: Proxied URL of author icon + :ivar Optional[str] url: URL of author + :ivar Optional[str] icon_url: URL of author icon + :ivar Optional[str] proxy_icon_url: Proxied URL of author icon """ name: str = field() @@ -316,8 +316,8 @@ class EmbedFooter(DictSerializerMixin): ) :ivar str text: Footer text - :ivar Optional[str] icon_url?: URL of footer icon - :ivar Optional[str] proxy_icon_url?: Proxied URL of footer icon + :ivar Optional[str] icon_url: URL of footer icon + :ivar Optional[str] proxy_icon_url: Proxied URL of footer icon """ text: str = field() @@ -353,7 +353,7 @@ class EmbedField(DictSerializerMixin): :ivar str name: Name of the field. :ivar str value: Value of the field - :ivar Optional[bool] inline?: A status denoting if the field should be displayed inline. + :ivar Optional[bool] inline: A status denoting if the field should be displayed inline. """ name: str = field() @@ -392,19 +392,19 @@ class Embed(DictSerializerMixin): fields=[interaction.EmbedField(...)], ) - :ivar Optional[str] title?: Title of embed - :ivar Optional[str] type?: Embed type, relevant by CDN file connected. This is only important to rendering. - :ivar Optional[str] description?: Embed description - :ivar Optional[str] url?: URL of embed - :ivar Optional[datetime] timestamp?: Timestamp of embed content - :ivar Optional[int] color?: Color code of embed - :ivar Optional[EmbedFooter] footer?: Footer information - :ivar Optional[EmbedImageStruct] image?: Image information - :ivar Optional[EmbedImageStruct] thumbnail?: Thumbnail information - :ivar Optional[EmbedImageStruct] video?: Video information - :ivar Optional[EmbedProvider] provider?: Provider information - :ivar Optional[EmbedAuthor] author?: Author information - :ivar Optional[List[EmbedField]] fields?: A list of fields denoting field information + :ivar Optional[str] title: Title of embed + :ivar Optional[str] type: Embed type, relevant by CDN file connected. This is only important to rendering. + :ivar Optional[str] description: Embed description + :ivar Optional[str] url: URL of embed + :ivar Optional[datetime] timestamp: Timestamp of embed content + :ivar Optional[int] color: Color code of embed + :ivar Optional[EmbedFooter] footer: Footer information + :ivar Optional[EmbedImageStruct] image: Image information + :ivar Optional[EmbedImageStruct] thumbnail: Thumbnail information + :ivar Optional[EmbedImageStruct] video: Video information + :ivar Optional[EmbedProvider] provider: Provider information + :ivar Optional[EmbedAuthor] author: Author information + :ivar Optional[List[EmbedField]] fields: A list of fields denoting field information """ title: Optional[str] = field(default=None) @@ -449,12 +449,9 @@ def add_field(self, name: str, value: str, inline: Optional[bool] = False) -> No """ Adds a field to the embed - :param name: The name of the field - :type name: str - :param value: The value of the field - :type value: str - :param inline?: if the field is in the same line as the previous one - :type inline?: Optional[bool] + :param str name: The name of the field + :param str value: The value of the field + :param Optional[bool] inline: if the field is in the same line as the previous one """ fields = self.fields or [] @@ -478,14 +475,10 @@ def insert_field_at( """ Inserts a field in the embed at the specified index - :param index: The field's index to insert - :type index: int - :param name: The name of the field - :type name: str - :param value: The value of the field - :type value: str - :param inline?: if the field is in the same line as the previous one - :type inline?: Optional[bool] + :param int index: The field's index to insert + :param str name: The name of the field + :param str value: The value of the field + :param Optional[bool] inline: if the field is in the same line as the previous one """ try: @@ -502,14 +495,10 @@ def set_field_at( """ Overwrites the field in the embed at the specified index - :param index: The field's index to overwrite - :type index: int - :param name: The name of the field - :type name: str - :param value: The value of the field - :type value: str - :param inline?: if the field is in the same line as the previous one - :type inline?: Optional[bool] + :param int index: The field's index to overwrite + :param str name: The name of the field + :param str value: The value of the field + :param Optional[bool] inline: if the field is in the same line as the previous one """ try: @@ -527,8 +516,7 @@ def remove_field(self, index: int) -> None: """ Remove field at the specified index - :param index: The field's index to remove - :type index: int + :param int index: The field's index to remove """ try: @@ -560,14 +548,10 @@ def set_author( """ Sets the embed's author - :param name: The name of the author - :type name: str - :param url?: Url of author - :type url?: Optional[str] - :param icon_url?: Url of author icon (only supports http(s) and attachments) - :type icon_url?: Optional[str] - :param proxy_icon_url?: A proxied url of author icon - :type proxy_icon_url?: Optional[str] + :param str name: The name of the author + :param Optional[str] url: Url of author + :param Optional[str] icon_url: Url of author icon (only supports http(s) and attachments) + :param Optional[str] proxy_icon_url: A proxied url of author icon """ self.author = EmbedAuthor( @@ -580,12 +564,9 @@ def set_footer( """ Sets the embed's footer - :param text: The text of the footer - :type text: str - :param icon_url?: Url of footer icon (only supports http(s) and attachments) - :type icon_url?: Optional[str] - :param proxy_icon_url?: A proxied url of footer icon - :type proxy_icon_url?: Optional[str] + :param str text: The text of the footer + :param Optional[str] icon_url: Url of footer icon (only supports http(s) and attachments) + :param Optional[str] proxy_icon_url: A proxied url of footer icon """ self.footer = EmbedFooter(text=text, icon_url=icon_url, proxy_icon_url=proxy_icon_url) @@ -600,14 +581,10 @@ def set_image( """ Sets the embed's image - :param url: Url of the image - :type url: str - :param proxy_url?: A proxied url of the image - :type proxy_url?: Optional[str] - :param height?: The image's height - :type height?: Optional[int] - :param width?: The image's width - :type width?: Optional[int] + :param str url: Url of the image + :param Optional[str] proxy_url: A proxied url of the image + :param Optional[int] height: The image's height + :param Optional[int] width: The image's width """ self.image = EmbedImageStruct(url=url, proxy_url=proxy_url, height=height, width=width) @@ -622,14 +599,10 @@ def set_video( """ Sets the embed's video - :param url: Url of the video - :type url: str - :param proxy_url?: A proxied url of the video - :type proxy_url?: Optional[str] - :param height?: The video's height - :type height?: Optional[int] - :param width?: The video's width - :type width?: Optional[int] + :param str url: Url of the video + :param Optional[str] proxy_url: A proxied url of the video + :param Optional[int] height: The video's height + :param Optional[int] width: The video's width """ self.video = EmbedImageStruct(url=url, proxy_url=proxy_url, height=height, width=width) @@ -644,14 +617,10 @@ def set_thumbnail( """ Sets the embed's thumbnail - :param url: Url of the thumbnail - :type url: str - :param proxy_url?: A proxied url of the thumbnail - :type proxy_url?: Optional[str] - :param height?: The thumbnail's height - :type height?: Optional[int] - :param width?: The thumbnail's width - :type width?: Optional[int] + :param str url: Url of the thumbnail + :param Optional[str] proxy_url: A proxied url of the thumbnail + :param Optional[int] height: The thumbnail's height + :param Optional[int] width: The thumbnail's width """ self.thumbnail = EmbedImageStruct(url=url, proxy_url=proxy_url, height=height, width=width) @@ -678,17 +647,17 @@ class Sticker(PartialSticker, IDMixin): A class object representing a full sticker apart from a partial. :ivar Snowflake id: ID of the sticker - :ivar Optional[Snowflake] pack_id?: ID of the pack the sticker is from. + :ivar Optional[Snowflake] pack_id: ID of the pack the sticker is from. :ivar str name: Name of the sticker - :ivar Optional[str] description?: Description of the sticker + :ivar Optional[str] description: Description of the sticker :ivar str tags: Autocomplete/suggestion tags for the sticker (max 200 characters) :ivar str asset: Previously a sticker asset hash, now an empty string. :ivar int type: Type of sticker :ivar int format_type: Type of sticker format - :ivar Optional[bool] available?: Status denoting if this sticker can be used. (Can be false via server boosting) - :ivar Optional[Snowflake] guild_id?: Guild ID that owns the sticker. - :ivar Optional[User] user?: The user that uploaded the sticker. - :ivar Optional[int] sort_value?: The standard sticker's sort order within its pack + :ivar Optional[bool] available: Status denoting if this sticker can be used. (Can be false via server boosting) + :ivar Optional[Snowflake] guild_id: Guild ID that owns the sticker. + :ivar Optional[User] user: The user that uploaded the sticker. + :ivar Optional[int] sort_value: The standard sticker's sort order within its pack """ id: Snowflake = field(converter=Snowflake) @@ -714,9 +683,9 @@ class StickerPack(DictSerializerMixin, IDMixin): :ivar List[Sticker] stickers: The stickers in the pack. :ivar str name: The name of sticker pack. :ivar Snowflake sku_id: ID of the pack's SKU. - :ivar Optional[Snowflake] cover_sticker_id?: ID of a sticker in the pack which is shown as the pack's icon. + :ivar Optional[Snowflake] cover_sticker_id: ID of a sticker in the pack which is shown as the pack's icon. :ivar str description: The description of sticker pack. - :ivar Optional[Snowflake] banned_asset_id?: ID of the sticker pack's banner image. + :ivar Optional[Snowflake] banned_asset_id: ID of the sticker pack's banner image. """ id: Snowflake = field(converter=Snowflake) From 5007152fcb4976879ea3349355d56561880e1563 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:04:42 +0100 Subject: [PATCH 17/32] update misc.py --- interactions/api/models/misc.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 8a55c934d..51c062d2a 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -62,9 +62,9 @@ class ClientStatus(DictSerializerMixin): """ An object that symbolizes the status per client device per session. - :ivar Optional[str] desktop?: User's status set for an active desktop application session - :ivar Optional[str] mobile?: User's status set for an active mobile application session - :ivar Optional[str] web?: User's status set for an active web application session + :ivar Optional[str] desktop: User's status set for an active desktop application session + :ivar Optional[str] mobile: User's status set for an active mobile application session + :ivar Optional[str] web: User's status set for an active web application session """ desktop: Optional[str] = field(default=None) @@ -118,6 +118,7 @@ def increment(self) -> int: def worker_id(self) -> int: """ This is the Internal Worker ID of the snowflake. + :return: An integer denoting the internal worker ID. """ return (int(self._snowflake) & 0x3E0000) >> 17 @@ -126,6 +127,7 @@ def worker_id(self) -> int: def process_id(self) -> int: """ This is the Internal Process ID of the snowflake. + :return: An integer denoting the internal process ID. """ return (int(self._snowflake) & 0x1F000) >> 12 @@ -398,10 +400,10 @@ class AllowedMentions(DictSerializerMixin): """ A class object representing the allowed mentions object - :ivar parse?: Optional[List[AllowedMentionType]]: An array of allowed mention types to parse from the content. - :ivar users?: Optional[List[int]]: An array of user ids to mention. - :ivar roles?: Optional[List[int]]: An array of role ids to mention. - :ivar replied_user?: Optional[bool]: For replies, whether to mention the author of the message being replied to. + :ivar Optional[List[AllowedMentionType]] parse: An array of allowed mention types to parse from the content. + :ivar Optional[List[int]] users: An array of user ids to mention. + :ivar Optional[List[int]] roles: An array of role ids to mention. + :ivar Optional[bool] replied_user: For replies, whether to mention the author of the message being replied to. """ parse: Optional[List[AllowedMentionType]] = field( From 2aaf64d7b1afda115213090ff87140aa7ab2e7cb Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:04:49 +0100 Subject: [PATCH 18/32] update presence.py --- interactions/api/models/presence.py | 52 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/interactions/api/models/presence.py b/interactions/api/models/presence.py index c116ee701..eb6183660 100644 --- a/interactions/api/models/presence.py +++ b/interactions/api/models/presence.py @@ -23,8 +23,8 @@ class PresenceParty(DictSerializerMixin): """ A class object representing the party data of a presence. - :ivar Optional[Snowflake] id?: ID of the party. - :ivar Optional[List[int]] size?: An array denoting the party's current and max size + :ivar Optional[Snowflake] id: ID of the party. + :ivar Optional[List[int]] size: An array denoting the party's current and max size """ id: Optional[Snowflake] = field(converter=Snowflake, default=None) @@ -36,10 +36,10 @@ class PresenceAssets(DictSerializerMixin): """ A class object representing the assets of a presence. - :ivar Optional[str] large_image?: ID for a large asset of the activity - :ivar Optional[str] large_text?: Text associated with the large asset - :ivar Optional[str] small_image?: ID for a small asset of the activity - :ivar Optional[str] small_text?: Text associated with the small asset + :ivar Optional[str] large_image: ID for a large asset of the activity + :ivar Optional[str] large_text: Text associated with the large asset + :ivar Optional[str] small_image: ID for a small asset of the activity + :ivar Optional[str] small_text: Text associated with the small asset """ large_image: Optional[str] = field(default=None) @@ -53,9 +53,9 @@ class PresenceSecrets(DictSerializerMixin): """ A class object representing "secret" join information of a presence. - :ivar Optional[str] join?: Join secret - :ivar Optional[str] spectate?: Spectate secret - :ivar Optional[str] match?: Instanced match secret + :ivar Optional[str] join: Join secret + :ivar Optional[str] spectate: Spectate secret + :ivar Optional[str] match: Instanced match secret """ join: Optional[str] = field(default=None) @@ -68,8 +68,8 @@ class PresenceTimestamp(DictSerializerMixin): """ A class object representing the timestamp data of a presence. - :ivar Optional[int] start?: Unix time in ms when the activity started - :ivar Optional[int] end?: Unix time in ms when the activity ended + :ivar Optional[int] start: Unix time in ms when the activity started + :ivar Optional[int] end: Unix time in ms when the activity ended """ start: Optional[int] = field(default=None) @@ -95,7 +95,7 @@ class PresenceActivity(DictSerializerMixin): A class object representing the current activity data of a presence. .. note:: - When using this model to instantiate alongside the client, if you provide a type 1 ( or PresenceActivityType.STREAMING ), + When using this model to instantiate alongside the client, if you provide a type :attr:`PresenceActivityType.STREAMING`, then the ``url`` attribute is necessary. The ``button`` attribute technically contains an object denoting Presence buttons. However, the gateway dispatches these @@ -103,19 +103,19 @@ class PresenceActivity(DictSerializerMixin): :ivar str name: The activity name :ivar Union[int, PresenceActivityType] type: The activity type - :ivar Optional[str] url?: stream url (if type is 1) + :ivar Optional[str] url: stream url (if type is :attr:`PresenceActivityType.STREAMING`) :ivar int created_at: Unix timestamp (in milliseconds) of when the activity was added to the user's session - :ivar Optional[PresenceTimestamp] timestamps?: Unix timestamps for start and/or end of the game - :ivar Optional[Snowflake] application_id?: Application ID for the game - :ivar Optional[str] details?: What the player is currently doing - :ivar Optional[str] state?: Current party status - :ivar Optional[Emoji] emoji?: The emoji used for the custom status - :ivar Optional[PresenceParty] party?: Info for the current players' party - :ivar Optional[PresenceAssets] assets?: Images for the presence and their associated hover texts - :ivar Optional[PresenceSecrets] secrets?: for RPC join/spectate - :ivar Optional[bool] instance?: A status denoting if the activity is a game session - :ivar Optional[int] flags?: activity flags - :ivar Optional[List[str]] buttons?: Custom button labels shown in the status, if any. + :ivar Optional[PresenceTimestamp] timestamps: Unix timestamps for start and/or end of the game + :ivar Optional[Snowflake] application_id: Application ID for the game + :ivar Optional[str] details: What the player is currently doing + :ivar Optional[str] state: Current party status + :ivar Optional[Emoji] emoji: The emoji used for the custom status + :ivar Optional[PresenceParty] party: Info for the current players' party + :ivar Optional[PresenceAssets] assets: Images for the presence and their associated hover texts + :ivar Optional[PresenceSecrets] secrets: for RPC join/spectate + :ivar Optional[bool] instance: A status denoting if the activity is a game session + :ivar Optional[int] flags: activity flags + :ivar Optional[List[str]] buttons: Custom button labels shown in the status, if any. """ name: str = field() @@ -150,7 +150,7 @@ def gateway_json(self) -> dict: .. note:: This is NOT used for standard presence activity reading by other users, i.e. User activity reading. - You can use the `_json` attribute instead. + You can use the ``_json`` attribute instead. """ res = {"name": self.name, "type": self.type} if self.url: @@ -163,7 +163,7 @@ class ClientPresence(DictSerializerMixin): """ An object that symbolizes the presence of the current client's session upon creation. - :ivar Optional[int] since?: Unix time in milliseconds of when the client went idle. None if it is not idle. + :ivar Optional[int] since: Unix time in milliseconds of when the client went idle. None if it is not idle. :ivar Optional[List[PresenceActivity]] activities: Array of activity objects. :ivar Union[str, StatusType] status: The client's new status. :ivar bool afk: Whether the client is afk or not. From f3038c39baeb7ea8088ba726cc8cdaa00ef1b6ac Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:04:54 +0100 Subject: [PATCH 19/32] update role.py --- interactions/api/models/role.py | 54 ++++++++++++--------------------- 1 file changed, 20 insertions(+), 34 deletions(-) diff --git a/interactions/api/models/role.py b/interactions/api/models/role.py index cb1b7bf78..0cd0d1687 100644 --- a/interactions/api/models/role.py +++ b/interactions/api/models/role.py @@ -19,9 +19,9 @@ class RoleTags(DictSerializerMixin): """ A class object representing the tags of a role. - :ivar Optional[Snowflake] bot_id?: The id of the bot this role belongs to - :ivar Optional[Snowflake] integration_id?: The id of the integration this role belongs to - :ivar Optional[Any] premium_subscriber?: Whether if this is the guild's premium subscriber role + :ivar Optional[Snowflake] bot_id: The id of the bot this role belongs to + :ivar Optional[Snowflake] integration_id: The id of the integration this role belongs to + :ivar Optional[Any] premium_subscriber: Whether if this is the guild's premium subscriber role """ bot_id: Optional[Snowflake] = field(converter=Snowflake, default=None) @@ -40,13 +40,13 @@ class Role(ClientSerializerMixin, IDMixin): :ivar str name: Role name :ivar int color: Role color in integer representation :ivar bool hoist: A status denoting if this role is hoisted - :ivar Optional[str] icon?: Role icon hash, if any. - :ivar Optional[str] unicode_emoji?: Role unicode emoji + :ivar Optional[str] icon: Role icon hash, if any. + :ivar Optional[str] unicode_emoji: Role unicode emoji :ivar int position: Role position :ivar str permissions: Role permissions as a bit set :ivar bool managed: A status denoting if this role is managed by an integration :ivar bool mentionable: A status denoting if this role is mentionable - :ivar Optional[RoleTags] tags?: The tags this role has + :ivar Optional[RoleTags] tags: The tags this role has """ id: Snowflake = field(converter=Snowflake) @@ -79,10 +79,8 @@ async def delete( """ Deletes the role from the guild. - :param guild_id: The id of the guild to delete the role from - :type guild_id: int - :param reason: The reason for the deletion - :type reason: Optional[str] + :param int guild_id: The id of the guild to delete the role from + :param Optional[str] reason: The reason for the deletion """ if not self._client: raise LibraryException(code=13) @@ -108,24 +106,15 @@ async def modify( """ Edits the role in a guild. - :param guild_id: The id of the guild to edit the role on - :type guild_id: int - :param name?: The name of the role, defaults to the current value of the role - :type name?: Optional[str] - :param color?: RGB color value as integer, defaults to the current value of the role - :type color?: Optional[int] - :param permissions?: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role - :type permissions?: Optional[int] - :param hoist?: Whether the role should be displayed separately in the sidebar, defaults to the current value of the role - :type hoist?: Optional[bool] - :param icon?: The role's icon image (if the guild has the ROLE_ICONS feature), defaults to the current value of the role - :type icon?: Optional[Image] - :param unicode_emoji?: The role's unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature), defaults to the current value of the role - :type unicode_emoji?: Optional[str] - :param mentionable?: Whether the role should be mentionable, defaults to the current value of the role - :type mentionable?: Optional[bool] - :param reason?: The reason why the role is edited, default ``None`` - :type reason?: Optional[str] + :param int guild_id: The id of the guild to edit the role on + :param Optional[str] name: The name of the role, defaults to the current value of the role + :param Optional[int] color: RGB color value as integer, defaults to the current value of the role + :param Optional[int] permissions: Bitwise value of the enabled/disabled permissions, defaults to the current value of the role + :param Optional[bool] hoist: Whether the role should be displayed separately in the sidebar, defaults to the current value of the role + :param Optional[Image] icon: The role's icon image (if the guild has the ROLE_ICONS feature), defaults to the current value of the role + :param Optional[str] unicode_emoji: The role's unicode emoji as a standard emoji (if the guild has the ROLE_ICONS feature), defaults to the current value of the role + :param Optional[bool] mentionable: Whether the role should be mentionable, defaults to the current value of the role + :param Optional[str] reason: The reason why the role is edited, default ``None`` :return: The modified role object :rtype: Role """ @@ -170,12 +159,9 @@ async def modify_position( """ Modifies the position of a role in the guild. - :param guild_id: The id of the guild to modify the role position on - :type guild_id: int - :param position: The new position of the role - :type position: int - :param reason?: The reason for the modifying - :type reason?: Optional[str] + :param int guild_id: The id of the guild to modify the role position on + :param int position: The new position of the role + :param Optional[str] reason: The reason for the modifying :return: List of guild roles with updated hierarchy :rtype: List[Role] """ From 6b0ba4e1a4ac5fafcb14a15f7fffb0424e9a7856 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:05:00 +0100 Subject: [PATCH 20/32] update team.py --- interactions/api/models/team.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/interactions/api/models/team.py b/interactions/api/models/team.py index 10beecce5..8104804bc 100644 --- a/interactions/api/models/team.py +++ b/interactions/api/models/team.py @@ -38,7 +38,7 @@ class Team(ClientSerializerMixin, IDMixin): """ A class object representing a team. - :ivar Optional[str] icon?: The hash of the team's icon + :ivar Optional[str] icon: The hash of the team's icon :ivar Snowflake id: The team's unique ID :ivar List[TeamMember] members: The members of the team :ivar str name: The team name @@ -62,22 +62,22 @@ class Application(ClientSerializerMixin, IDMixin): :ivar Snowflake id: Application ID :ivar str name: Application Name - :ivar Optional[str] icon?: Icon hash of the application + :ivar Optional[str] icon: Icon hash of the application :ivar str description: Application Description - :ivar Optional[List[str]] rpc_origins?: An array of rpc origin urls, if RPC is used. + :ivar Optional[List[str]] rpc_origins: An array of rpc origin urls, if RPC is used. :ivar bool bot_public: A status denoting if anyone can invite the bot to guilds :ivar bool bot_require_code_grant: A status denoting whether full Oauth2 is required for the app's bot to join a guild - :ivar Optional[str] terms_of_service_url?: URL of the app's Terms of Service - :ivar Optional[str] privacy_policy_url?: URL of the app's Privacy Policy - :ivar Optional[User] owner?: User object of the owner + :ivar Optional[str] terms_of_service_url: URL of the app's Terms of Service + :ivar Optional[str] privacy_policy_url: URL of the app's Privacy Policy + :ivar Optional[User] owner: User object of the owner :ivar str summary: Summary of the store page, if this application is a game sold on Discord :ivar str verify_key: Hex encoded key for verification in interactions and/or the GameSDK's GetTicket - :ivar Optional[Team] team?: A list of team members, if this app belongs to a team. - :ivar Optional[Snowflake] guild_id?: Guild ID linked, if this app is a game sold on Discord - :ivar Optional[int] primary_sku_id?: Game SKU ID, if this app is a game sold on Discord - :ivar Optional[str] slug?: URL slug that links to the store page, if this app is a game sold on Discord - :ivar Optional[str] cover_image?: The app's default rich presence invite cover image - :ivar Optional[AppFlags] flags?: The application's public flags + :ivar Optional[Team] team: A list of team members, if this app belongs to a team. + :ivar Optional[Snowflake] guild_id: Guild ID linked, if this app is a game sold on Discord + :ivar Optional[int] primary_sku_id: Game SKU ID, if this app is a game sold on Discord + :ivar Optional[str] slug: URL slug that links to the store page, if this app is a game sold on Discord + :ivar Optional[str] cover_image: The app's default rich presence invite cover image + :ivar Optional[AppFlags] flags: The application's public flags """ id: Snowflake = field(converter=Snowflake) From b3dac66176a5b83c994f7de41c1ee053955002a4 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:05:04 +0100 Subject: [PATCH 21/32] update user.py --- interactions/api/models/user.py | 48 +++++++++++++++------------------ 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/interactions/api/models/user.py b/interactions/api/models/user.py index 97a5b87cf..c59f8ae03 100644 --- a/interactions/api/models/user.py +++ b/interactions/api/models/user.py @@ -22,19 +22,19 @@ class User(ClientSerializerMixin, IDMixin): :ivar Snowflake id: The User ID :ivar str username: The Username associated (not necessarily unique across the platform) :ivar str discriminator: The User's 4-digit discord-tag (i.e.: XXXX) - :ivar Optional[str] avatar?: The user's avatar hash, if any - :ivar Optional[bool] bot?: A status denoting if the user is a bot - :ivar Optional[bool] system?: A status denoting if the user is an Official Discord System user - :ivar Optional[bool] mfa_enabled?: A status denoting if the user has 2fa on their account - :ivar Optional[str] banner?: The user's banner hash, if any - :ivar Optional[str] banner_color?: The user's banner color as a hex, if any - :ivar Optional[int] accent_color?: The user's banner color as an integer represented of hex color codes - :ivar Optional[str] locale?: The user's chosen language option - :ivar Optional[bool] verified?: Whether the email associated with this account has been verified - :ivar Optional[str] email?: The user's email, if any - :ivar Optional[UserFlags] flags?: The user's flags - :ivar Optional[int] premium_type?: The type of Nitro subscription the user has - :ivar Optional[UserFlags] public_flags?: The user's public flags + :ivar Optional[str] avatar: The user's avatar hash, if any + :ivar Optional[bool] bot: A status denoting if the user is a bot + :ivar Optional[bool] system: A status denoting if the user is an Official Discord System user + :ivar Optional[bool] mfa_enabled: A status denoting if the user has 2fa on their account + :ivar Optional[str] banner: The user's banner hash, if any + :ivar Optional[str] banner_color: The user's banner color as a hex, if any + :ivar Optional[int] accent_color: The user's banner color as an integer represented of hex color codes + :ivar Optional[str] locale: The user's chosen language option + :ivar Optional[bool] verified: Whether the email associated with this account has been verified + :ivar Optional[str] email: The user's email, if any + :ivar Optional[UserFlags] flags: The user's flags + :ivar Optional[int] premium_type: The type of Nitro subscription the user has + :ivar Optional[UserFlags] public_flags: The user's public flags """ id: Snowflake = field(converter=Snowflake) @@ -59,6 +59,7 @@ def __str__(self) -> str: return self.username def has_public_flag(self, flag: Union[UserFlags, int]) -> bool: + """Returns whether the user has public flag.""" if self.public_flags == 0 or self.public_flags is None: return False return bool(int(self.public_flags) & flag) @@ -139,20 +140,13 @@ async def send( """ Sends a DM to the user. - :param content?: The contents of the message as a string or string-converted value. - :type content?: Optional[str] - :param components?: A component, or list of components for the message. - :type components?: Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] - :param tts?: Whether the message utilizes the text-to-speech Discord programme or not. - :type tts?: Optional[bool] - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param files?: A file or list of files to be attached to the message. - :type files?: Optional[Union[File, List[File]]] - :param embeds?: An embed, or list of embeds for the message. - :type embeds?: Optional[Union[Embed, List[Embed]]] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] + :param Optional[str] content: The contents of the message as a string or string-converted value. + :param Optional[Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]]] components: A component, or list of components for the message. + :param Optional[bool] tts: Whether the message utilizes the text-to-speech Discord programme or not. + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Optional[Union[File, List[File]]] files: A file or list of files to be attached to the message. + :param Optional[Union[Embed, List[Embed]]] embeds: An embed, or list of embeds for the message. + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. :return: The sent message as an object. :rtype: Message """ From 6a03207483704217c1090e03666de9977c553be1 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:05:11 +0100 Subject: [PATCH 22/32] update webhook.py --- interactions/api/models/webhook.py | 72 +++++++++++------------------- 1 file changed, 26 insertions(+), 46 deletions(-) diff --git a/interactions/api/models/webhook.py b/interactions/api/models/webhook.py index 4b8898ca4..b8ffb9fb0 100644 --- a/interactions/api/models/webhook.py +++ b/interactions/api/models/webhook.py @@ -31,16 +31,16 @@ class Webhook(ClientSerializerMixin, IDMixin): :ivar Snowflake id: the id of the webhook :ivar WebhookType type: the type of the webhook - :ivar Snowflake guild_id?: the guild id this webhook is for, if any - :ivar Snowflake channel_id?: the channel id this webhook is for, if any - :ivar User user?: the user this webhook was created by (not returned when getting a webhook with its token) + :ivar Snowflake guild_id: the guild id this webhook is for, if any + :ivar Snowflake channel_id: the channel id this webhook is for, if any + :ivar User user: the user this webhook was created by (not returned when getting a webhook with its token) :ivar str name: the default name of the webhook :ivar str avatar: the default user avatar hash of the webhook :ivar str token: the secure token of the webhook (returned for Incoming Webhooks) :ivar Snowflake application_id: the bot/OAuth2 application that created this webhook - :ivar Guild source_guild?: the guild of the channel that this webhook is following (returned for Channel Follower Webhooks) - :ivar Channel source_channel?: the channel that this webhook is following (returned for Channel Follower Webhooks) - :ivar str url?: the url used for executing the webhook (returned by the webhooks OAuth2 flow) + :ivar Guild source_guild: the guild of the channel that this webhook is following (returned for Channel Follower Webhooks) + :ivar Channel source_channel: the channel that this webhook is following (returned for Channel Follower Webhooks) + :ivar str url: the url used for executing the webhook (returned by the webhooks OAuth2 flow) """ id: Snowflake = field(converter=Snowflake) @@ -83,14 +83,10 @@ async def create( """ Creates a webhook in a channel. - :param client: The HTTPClient of the bot, has to be set to `bot._http`. - :type client: HTTPClient - :param channel_id: The ID of the channel to create the webhook in. - :type channel_id: int - :param name: The name of the webhook. - :type name: str - :param avatar: The avatar of the Webhook, if any. - :type avatar: Optional[Image] + :param HTTPClient client: The HTTPClient of the bot, has to be set to ``bot._http``. + :param int channel_id: The ID of the channel to create the webhook in. + :param str name: The name of the webhook. + :param Optional[Image] avatar: The avatar of the Webhook, if any. :return: The created webhook as object :rtype: Webhook """ @@ -111,12 +107,9 @@ async def get( """ Gets an existing webhook. - :param client: The HTTPClient of the bot, has to be set to `bot._http`. - :type client: HTTPClient - :param webhook_id: The ID of the webhook. - :type webhook_id: int - :param webhook_token: The token of the webhook, optional - :type webhook_token: Optional[str] + :param HTTPClient client: The HTTPClient of the bot, has to be set to ``bot._http``. + :param int webhook_id: The ID of the webhook. + :param Optional[str] webhook_token: The token of the webhook, optional :return: The Webhook object :rtype: Webhook """ @@ -136,12 +129,9 @@ async def modify( """ Modifies the current webhook. - :param name: The new name of the webhook - :type name: Optional[str] - :param channel_id: The channel id of the webhook. If not provided, the webhook token will be used for authentication - :type channel_id: int - :param avatar: The new avatar of the webhook - :type avatar: Optional[Image] + :param Optional[str] name: The new name of the webhook + :param int channel_id: The channel id of the webhook. If not provided, the webhook token will be used for authentication + :param Optional[Image] avatar: The new avatar of the webhook :return: The modified webhook object :rtype: Webhook """ @@ -202,26 +192,16 @@ async def execute( .. important:: The ``components`` argument requires an application-owned webhook. - :param content: the message contents (up to 2000 characters) - :type content: str - :param username: override the default username of the webhook - :type username: str - :param avatar_url: override the default avatar of the webhook - :type avatar_url: str - :param tts: true if this is a TTS message - :type tts: bool - :param attachments?: The attachments to attach to the message. Needs to be uploaded to the CDN first - :type attachments?: Optional[List[Attachment]] - :param embeds: embedded ``rich`` content - :type embeds: Union[Embed, List[Embed]] - :param allowed_mentions?: The allowed mentions for the message. - :type allowed_mentions?: Optional[Union[AllowedMentions, dict]] - :param components: the components to include with the message - :type components: Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] - :param files: The files to attach to the message - :type files: Union[File, List[File]] - :param thread_id: Send a message to a specified thread within a webhook's channel. The thread will automatically be unarchived - :type thread_id: int + :param str content: the message contents (up to 2000 characters) + :param str username: override the default username of the webhook + :param str avatar_url: override the default avatar of the webhook + :param bool tts: true if this is a TTS message + :param Optional[List[Attachment]] attachments: The attachments to attach to the message. Needs to be uploaded to the CDN first + :param Union[Embed, List[Embed]] embeds: embedded ``rich`` content + :param Optional[Union[AllowedMentions, dict]] allowed_mentions: The allowed mentions for the message. + :param Union[ActionRow, Button, SelectMenu, List[ActionRow], List[Button], List[SelectMenu]] components: the components to include with the message + :param Union[File, List[File]] files: The files to attach to the message + :param int thread_id: Send a message to a specified thread within a webhook's channel. The thread will automatically be unarchived :return: The sent message, if present :rtype: Optional[Message] """ From 10d15beea6b1dbf4afc6f7adcff302b8ee783f57 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:10:00 +0100 Subject: [PATCH 23/32] update cache, dispatch & error --- interactions/api/cache.py | 21 +++++++-------------- interactions/api/dispatch.py | 15 +++++---------- interactions/api/error.py | 7 ++----- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/interactions/api/cache.py b/interactions/api/cache.py index c4218fbd2..c823c068f 100644 --- a/interactions/api/cache.py +++ b/interactions/api/cache.py @@ -45,10 +45,8 @@ def merge(self, item: _T, id: Optional["Key"] = None) -> None: """ Merges new data of an item into an already present item of the cache - :param item: The item to merge. - :type item: Any - :param id: The unique id of the item. - :type id: Optional[Union[Snowflake, Tuple[Snowflake, Snowflake]]] + :param Any item: The item to merge. + :param Optional[Union[Snowflake, Tuple[Snowflake, Snowflake]]] id: The unique id of the item. """ if not self.values.get(id or item.id): return self.add(item, id) @@ -82,10 +80,8 @@ def add(self, item: _T, id: Optional["Key"] = None) -> None: """ Adds a new item to the storage. - :param item: The item to add. - :type item: Any - :param id: The unique id of the item. - :type id: Optional[Union[Snowflake, Tuple[Snowflake, Snowflake]]] + :param Any item: The item to add. + :param Optional[Union[Snowflake, Tuple[Snowflake, Snowflake]]] id: The unique id of the item. """ self.values[id or item.id] = item @@ -101,10 +97,8 @@ def get(self, id: "Key", default: Optional[_P] = None) -> Union[_T, _P, None]: """ Gets an item from the storage. - :param id: The ID of the item. - :type id: Union[Snowflake, Tuple[Snowflake, Snowflake]] - :param default: The default value to return if the item is not found. - :type default: Optional[Any] + :param Union[Snowflake, Tuple[Snowflake, Snowflake]] id: The ID of the item. + :param Optional[Any] default: The default value to return if the item is not found. :return: The item from the storage if any. :rtype: Optional[Any] """ @@ -114,8 +108,7 @@ def update(self, data: Dict["Key", _T]): """ Updates multiple items from the storage. - :param data: The data to update with. - :type data: dict + :param dict data: The data to update with. """ self.values.update(data) diff --git a/interactions/api/dispatch.py b/interactions/api/dispatch.py index 1dbb80e21..78b213b64 100644 --- a/interactions/api/dispatch.py +++ b/interactions/api/dispatch.py @@ -27,12 +27,9 @@ def dispatch(self, __name: str, *args, **kwargs) -> None: r""" Dispatches an event given out by the gateway. - :param __name: The name of the event to dispatch. - :type __name: str - :param \*args: Multiple arguments of the coroutine. - :type \*args: list[Any] - :param \**kwargs: Keyword-only arguments of the coroutine. - :type \**kwargs: dict + :param str __name: The name of the event to dispatch. + :param list[Any] \*args: Multiple arguments of the coroutine. + :param dict \**kwargs: Keyword-only arguments of the coroutine. """ for event in self.events.get(__name, []): converters: dict @@ -55,10 +52,8 @@ def register(self, coro: Callable[..., Coroutine], name: Optional[str] = None) - i.e. : async def on_guild_create -> "ON_GUILD_CREATE" dispatch. - :param coro: The coroutine to register as an event. - :type coro: Callable[..., Coroutine] - :param name?: The name to associate the coroutine with. Defaults to None. - :type name?: Optional[str] + :param Callable[..., Coroutine] coro: The coroutine to register as an event. + :param Optional[str] name: The name to associate the coroutine with. Defaults to None. """ _name: str = coro.__name__ if name is None else name event = self.events.get(_name, []) diff --git a/interactions/api/error.py b/interactions/api/error.py index ea1be79ff..15dcb6c45 100644 --- a/interactions/api/error.py +++ b/interactions/api/error.py @@ -23,8 +23,7 @@ def _parse(_data: dict) -> List[tuple]: Internal function that should not be executed externally. Parse the error data and set the code and message. - :param _data: The error data to parse. - :type _data: dict + :param dict _data: The error data to parse. :return: A list of tuples containing parsed errors. :rtype: List[tuple] """ @@ -55,10 +54,8 @@ def log(self, message: str, *args): """ Log the error message. - :param message: - :type message: + :param str message: :param args: - :type args: """ if self.severity == 0: # NOTSET pass From 48034181392629b1530bbd298e5fb9009f7ca9ed Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:18:46 +0100 Subject: [PATCH 24/32] update api.gateway --- interactions/api/gateway/client.py | 93 +++++++++------------------ interactions/api/gateway/heartbeat.py | 3 +- 2 files changed, 32 insertions(+), 64 deletions(-) diff --git a/interactions/api/gateway/client.py b/interactions/api/gateway/client.py index e9fd15579..5bf38c24e 100644 --- a/interactions/api/gateway/client.py +++ b/interactions/api/gateway/client.py @@ -124,14 +124,10 @@ def __init__( sequence: Optional[int] = MISSING, ) -> None: """ - :param token: The token of the application for connecting to the Gateway. - :type token: str - :param intents: The Gateway intents of the application for event dispatch. - :type intents: Intents - :param session_id?: The ID of the session if trying to reconnect. Defaults to ``None``. - :type session_id?: Optional[str] - :param sequence?: The identifier sequence if trying to reconnect. Defaults to ``None``. - :type sequence?: Optional[int] + :param str token: The token of the application for connecting to the Gateway. + :param Intents intents: The Gateway intents of the application for event dispatch. + :param Optional[str] session_id: The ID of the session if trying to reconnect. Defaults to ``None``. + :param Optional[int] sequence: The identifier sequence if trying to reconnect. Defaults to ``None``. """ try: self._loop = get_event_loop() if version_info < (3, 10) else get_running_loop() @@ -280,8 +276,7 @@ async def _handle_stream(self, stream: Dict[str, Any]): .. note :: This should never be called directly. - :param stream: The packet stream to handle. - :type stream: Dict[str, Any] + :param Dict[str, Any] stream: The packet stream to handle. """ op: Optional[int] = stream.get("op") event: Optional[str] = stream.get("t") @@ -334,10 +329,8 @@ def _dispatch_event(self, event: str, data: dict) -> None: """ Dispatches an event from the Gateway. - :param event: The name of the event. - :type event: str - :param data: The data for the event. - :type data: dict + :param str event: The name of the event. + :param dict data: The data for the event. """ self._dispatch.dispatch("raw_socket_create", event, data) path: str = "interactions" @@ -559,12 +552,9 @@ def __get_object_id( """ Gets an ID from object. - :param data: The data for the event. - :type data: dict - :param obj: The object of the event. - :type obj: Any - :param model: The model of the event. - :type model: type + :param dict data: The data for the event. + :param Any obj: The object of the event. + :param type model: The model of the event. :return: Object ID :rtype: Optional[Union[Snowflake, Tuple[Snowflake, Snowflake]]] """ @@ -597,10 +587,8 @@ def __get_object_ids(self, obj: Any, model: type) -> Optional[List[Snowflake]]: """ Gets a list of ids of object. - :param obj: The object of the event. - :type obj: Any - :param model: The model of the event. - :type model: type + :param Any obj: The object of the event. + :param type model: The model of the event. :return: Object IDs :rtype: Optional[Union[Snowflake, Tuple[Snowflake, Snowflake]]] """ @@ -630,14 +618,10 @@ def __modify_guild_cache( """ Modifies guild cache. - :param event: The name of the event. - :type event: str - :param data: The data for the event. - :type data: dict - :param obj: The object of the event. - :type obj: Any - :param model: The model of the event. - :type model: Any + :param str event: The name of the event. + :param dict data: The data for the event. + :param Any obj: The object of the event. + :param Any model: The model of the event. """ if not ( (guild_id := data.get("guild_id")) @@ -692,8 +676,7 @@ def __contextualize(self, data: dict) -> "_Context": Takes raw data given back from the Gateway and gives "context" based off of what it is. - :param data: The data from the Gateway. - :type data: dict + :param dict data: The data from the Gateway. :return: The context object. :rtype: Any """ @@ -721,10 +704,8 @@ def __sub_command_context( Checks if an application command schema has sub commands needed for argument collection. - :param data: The data structure of the option. - :type data: Union[dict, Option] - :param context: The context to refer subcommands from. - :type context: object + :param Union[dict, Option] data: The data structure of the option. + :param _Context context: The context to refer subcommands from. :return: A dictionary of the collected options, if any. :rtype: Union[Tuple[str], dict] """ @@ -807,10 +788,8 @@ def __option_type_context(self, context: "_Context", type: int) -> dict: Looks up the type of option respective to the existing option types. - :param context: The context to refer types from. - :type context: object - :param type: The option type. - :type type: int + :param _Context context: The context to refer types from. + :param int type: The option type. :return: The option type context. :rtype: dict """ @@ -974,8 +953,7 @@ async def _send_packet(self, data: Dict[str, Any]) -> None: """ Sends a packet to the Gateway. - :param data: The data to send to the Gateway. - :type data: Dict[str, Any] + :param Dict[str, Any] data: The data to send to the Gateway. """ _data = dumps(data) if isinstance(data, dict) else data packet: str = _data.decode("utf-8") if isinstance(_data, bytes) else _data @@ -1007,10 +985,8 @@ async def __identify( """ Sends an ``IDENTIFY`` packet to the gateway. - :param shard?: The shard ID to identify under. - :type shard?: Optional[List[Tuple[int]]] - :param presence?: The presence to change the bot to on identify. - :type presence?: Optional[ClientPresence] + :param Optional[List[Tuple[int]]] shard: The shard ID to identify under. + :param Optional[ClientPresence] presence: The presence to change the bot to on identify. """ self.__shard = shard self.__presence = presence @@ -1072,8 +1048,7 @@ async def _update_presence(self, presence: ClientPresence) -> None: As there's no gateway ratelimiter yet, breaking this ratelimit will force your bot to disconnect. - :param presence: The presence to change the bot to on identify. - :type presence: ClientPresence + :param ClientPresence presence: The presence to change the bot to on identify. """ payload: dict = {"op": OpCodeType.PRESENCE.value, "d": presence._json} await self._send_packet(payload) @@ -1091,18 +1066,12 @@ async def request_guild_members( ) -> None: """Sends an ``REQUEST_MEMBERS`` packet to the gateway. - :param guild_id: ID of the guild to get members for. - :type guild_id: int - :param limit: Maximum number of members to send matching the 'query' parameter. Required when specifying 'query'. - :type limit: int - :param query: String that username starts with. - :type query: Optional[str] - :param presences: Used to specify if we want the presences of the matched members. - :type presences: Optional[bool] - :param user_ids: Used to specify which users you wish to fetch. - :type user_ids: Optional[Union[int, List[int]]] - :param nonce: Nonce to identify the Guild Members Chunk response. - :type nonce: Optional[str] + :param int guild_id: ID of the guild to get members for. + :param int limit: Maximum number of members to send matching the 'query' parameter. Required when specifying 'query'. + :param Optional[str] query: String that username starts with. + :param Optional[bool] presences: Used to specify if we want the presences of the matched members. + :param Optional[Union[int, List[int]]] user_ids: Used to specify which users you wish to fetch. + :param Optional[str] nonce: Nonce to identify the Guild Members Chunk response. """ _data: dict = {"guild_id": guild_id, "query": query or "", "limit": limit} if presences is not None: diff --git a/interactions/api/gateway/heartbeat.py b/interactions/api/gateway/heartbeat.py index 14731477e..d4d34ba57 100644 --- a/interactions/api/gateway/heartbeat.py +++ b/interactions/api/gateway/heartbeat.py @@ -13,8 +13,7 @@ class _Heartbeat: def __init__(self, loop: AbstractEventLoop) -> None: """ - :param loop: The event loop to base the asynchronous manager. - :type loop: AbstractEventLoop + :param AbstractEventLoop loop: The event loop to base the asynchronous manager. """ with contextlib.suppress(TypeError): self.event = Event(loop=loop) if version_info < (3, 10) else Event() From 22acb3c8225d1e1a9c197d7caed418b75a3da8bd Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:20:26 +0100 Subject: [PATCH 25/32] fix: missing few places --- interactions/api/models/guild.py | 4 ++-- interactions/api/models/gw.py | 8 ++++---- interactions/client/bot.py | 3 +-- interactions/client/models/command.py | 6 ++---- interactions/utils/utils.py | 4 ++-- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index 0a2671b04..bca1a7db4 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -1337,7 +1337,7 @@ async def set_verification_level( Sets the verification level of the guild. :param VerificationLevel verification_level: The new verification level of the guild - :param Optional[str] reason?: The reason of the edit + :param Optional[str] reason: The reason of the edit """ return await self.modify(verification_level=verification_level, reason=reason) @@ -2774,7 +2774,7 @@ class EventMetadata(DictSerializerMixin): """ A class object representing the metadata of an event entity. - :ivar Optional[str] location?: The location of the event, if any. + :ivar Optional[str] location: The location of the event, if any. """ location: Optional[str] = field(default=None) diff --git a/interactions/api/models/gw.py b/interactions/api/models/gw.py index 6aae9c9c0..e8f5f4bb9 100644 --- a/interactions/api/models/gw.py +++ b/interactions/api/models/gw.py @@ -310,7 +310,7 @@ class GuildRole(ClientSerializerMixin): :ivar Snowflake guild_id: The guild ID of the event. :ivar Optional[Role] role: The role of the event. - :ivar Optional[Snowflake] role_id?: The role ID of the event. + :ivar Optional[Snowflake] role_id: The role ID of the event. """ guild_id: Snowflake = field(converter=Snowflake) @@ -504,11 +504,11 @@ class MessageReactionRemove(MessageReaction): This class inherits the already existing attributes of :class:`.MessageReaction`. The main missing attribute is ``member``. - :ivar Optional[Snowflake] user_id?: The user ID of the event. + :ivar Optional[Snowflake] user_id: The user ID of the event. :ivar Snowflake channel_id: The channel ID of the event. :ivar Snowflake message_id: The message ID of the event. - :ivar Optional[Snowflake] guild_id?: The guild ID of the event. - :ivar Optional[Emoji] emoji?: The emoji of the event. + :ivar Optional[Snowflake] guild_id: The guild ID of the event. + :ivar Optional[Emoji] emoji: The emoji of the event. """ # todo see if the missing member attribute affects anything diff --git a/interactions/client/bot.py b/interactions/client/bot.py index 9235b9464..30d898e63 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -1169,8 +1169,7 @@ def _find_command(self, command: Union[str, int]) -> ApplicationCommand: """ Iterates over `commands` and returns an :class:`ApplicationCommand` if it matches the name from `command` - :param command: The name or ID of the command to match - :type command: Union[str, int] + :param Union[str, int] command: The name or ID of the command to match :return: An ApplicationCommand model :rtype: ApplicationCommand """ diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index ff95c8625..77e326bef 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -434,10 +434,8 @@ def __call__(self, *args, **kwargs) -> Awaitable: r""" Returns the coroutine of the command as an awaitable. - :param \*args: Multiple positional arguments able to be passed through. - :type \*args: tuple - :param \**kwargs: Multiple key-word arguments able to be passed through. - :type \**kwargs: dict + :param tuple \*args: Multiple positional arguments able to be passed through. + :param dict \**kwargs: Multiple key-word arguments able to be passed through. :return: The awaitable of the command. :rtype: Awaitable """ diff --git a/interactions/utils/utils.py b/interactions/utils/utils.py index 5c8cce18f..fb76217ea 100644 --- a/interactions/utils/utils.py +++ b/interactions/utils/utils.py @@ -57,8 +57,8 @@ async def command(ctx): await ctx.send("I'm awake now!") :param Optional[Union[float, int]] delay: The amount of time in seconds to wait before defering the command. Defaults to ``2`` seconds. - :param Optional[bool] ephemeral?: Whether the command is deferred ephemerally. Defaults to ``False``. - :param Optional[bool] edit_origin?: Whether the command is deferred on origin. Defaults to ``False``. + :param Optional[bool] ephemeral: Whether the command is deferred ephemerally. Defaults to ``False``. + :param Optional[bool] edit_origin: Whether the command is deferred on origin. Defaults to ``False``. :return: The inner function, for decorating. :rtype: """ From 9a9e83a8c29f6f15e95e1a46ef24ab2861561ea8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 6 Oct 2022 18:29:27 +0000 Subject: [PATCH 26/32] ci: correct from checks. --- docs/api.rst | 2 -- interactions/api/models/gw.py | 6 ++++-- interactions/api/models/misc.py | 4 +++- interactions/client/models/command.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 17beec48c..34718b88e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -46,5 +46,3 @@ This page outlines the API reference of interactions.py. :caption: External Framework ext.rst - - diff --git a/interactions/api/models/gw.py b/interactions/api/models/gw.py index e8f5f4bb9..987cf9bbe 100644 --- a/interactions/api/models/gw.py +++ b/interactions/api/models/gw.py @@ -1,6 +1,7 @@ from datetime import datetime from typing import Any, List, Optional +from ...client.enums import PermissionType from ...utils.attrs_utils import ( ClientSerializerMixin, DictSerializerMixin, @@ -8,7 +9,6 @@ define, field, ) -from ...client.enums import PermissionType from .channel import Channel, ThreadMember from .emoji import Emoji from .guild import EventMetadata @@ -160,7 +160,9 @@ class ApplicationCommandPermissions(ClientSerializerMixin, IDMixin): application_id: Snowflake = field(converter=Snowflake) guild_id: Snowflake = field(converter=Snowflake) id: Snowflake = field(converter=Snowflake) - permissions: List[ApplicationCommandPermission] = field(converter=convert_list(ApplicationCommandPermission)) + permissions: List[ApplicationCommandPermission] = field( + converter=convert_list(ApplicationCommandPermission) + ) @define() diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 51c062d2a..67f328d1c 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -252,7 +252,9 @@ class AutoModTriggerMetadata(DictSerializerMixin): """ keyword_filter: Optional[List[str]] = field(default=None) - presets: Optional[List[AutoModKeywordPresetTypes]] = field(converter=convert_list(AutoModKeywordPresetTypes)) + presets: Optional[List[AutoModKeywordPresetTypes]] = field( + converter=convert_list(AutoModKeywordPresetTypes) + ) allow_list: Optional[List[str]] = field(default=None) mention_total_limit: Optional[int] = field(default=None) diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index 77e326bef..0205a0600 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -798,7 +798,7 @@ async def __call( param_len, ) # index of *args par_opts = list(params.keys())[ - (num := 2 if self.extension else 1): ( + (num := 2 if self.extension else 1) : ( -1 if last.kind in (last.VAR_POSITIONAL, last.VAR_KEYWORD) else index_of_var_pos ) ] # parameters that are before *args and **kwargs From 6d15d885ab09e373be98ef3d47a90045d8a4c8ad Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Thu, 6 Oct 2022 19:49:04 +0100 Subject: [PATCH 27/32] update --- docs/api.http.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.http.rst b/docs/api.http.rst index c7bd41f87..500840097 100644 --- a/docs/api.http.rst +++ b/docs/api.http.rst @@ -3,7 +3,7 @@ HTTP ==== -.. warning:: +.. important:: This page shows internal functions that you should not use unless you know how to use them. Most of these functions should have their own implementation in the different Models of the library. From 95f2a37be64ed74fafafe0c96cbc2bfe9b85daa3 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Sun, 9 Oct 2022 22:10:20 +0100 Subject: [PATCH 28/32] fix args type --- interactions/api/dispatch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interactions/api/dispatch.py b/interactions/api/dispatch.py index 78b213b64..42db3c580 100644 --- a/interactions/api/dispatch.py +++ b/interactions/api/dispatch.py @@ -28,7 +28,7 @@ def dispatch(self, __name: str, *args, **kwargs) -> None: Dispatches an event given out by the gateway. :param str __name: The name of the event to dispatch. - :param list[Any] \*args: Multiple arguments of the coroutine. + :param tuple \*args: Multiple arguments of the coroutine. :param dict \**kwargs: Keyword-only arguments of the coroutine. """ for event in self.events.get(__name, []): From 25baf66e8475702339386cdf632aa21fdf45c7ab Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Mon, 31 Oct 2022 22:01:28 +0000 Subject: [PATCH 29/32] feat: remove http files from docs --- docs/api.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 34718b88e..1b4b1edb0 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -35,12 +35,6 @@ This page outlines the API reference of interactions.py. utils.rst -.. toctree:: - :maxdepth: 1 - :caption: HTTP - - api.http.rst - .. toctree:: :maxdepth: 1 :caption: External Framework From ecbf91a6e20e1c382519bf7b3e202d07ffdbb673 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Mon, 31 Oct 2022 23:28:02 +0000 Subject: [PATCH 30/32] fix: add back HTTP page but hide it from search index --- docs/api.http.rst | 2 ++ docs/api.rst | 6 ++++++ interactions/api/models/misc.py | 1 + 3 files changed, 9 insertions(+) diff --git a/docs/api.http.rst b/docs/api.http.rst index 500840097..97e6a5d14 100644 --- a/docs/api.http.rst +++ b/docs/api.http.rst @@ -1,3 +1,5 @@ +:nosearch: + .. currentmodule:: interactions HTTP diff --git a/docs/api.rst b/docs/api.rst index 1b4b1edb0..34718b88e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -35,6 +35,12 @@ This page outlines the API reference of interactions.py. utils.rst +.. toctree:: + :maxdepth: 1 + :caption: HTTP + + api.http.rst + .. toctree:: :maxdepth: 1 :caption: External Framework diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 4523eb807..6a6b4d01c 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -263,6 +263,7 @@ class AutoModTriggerMetadata(DictSerializerMixin): class Color(IntEnum): """ An object representing Discord branding colors. + .. note:: This object only intends to cover the branding colors and no others. The main reason behind this is due to From c5750852f86e4f79c0d165b4b3da3b0cc13e2868 Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Tue, 1 Nov 2022 11:45:54 +0000 Subject: [PATCH 31/32] fix: actually remove HTTP methods from search index --- docs/api.http.rst | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/api.http.rst b/docs/api.http.rst index 97e6a5d14..1abccf80d 100644 --- a/docs/api.http.rst +++ b/docs/api.http.rst @@ -1,5 +1,3 @@ -:nosearch: - .. currentmodule:: interactions HTTP @@ -11,48 +9,64 @@ HTTP .. autoclass:: interactions.api.http.route.Route :members: + :noindex: .. autoclass:: interactions.api.http.limiter.Limiter :members: + :noindex: .. autoclass:: interactions.api.http.request._Request :members: + :noindex: .. autoclass:: interactions.api.http.client.HTTPClient :members: + :noindex: .. autoclass:: interactions.api.http.channel.ChannelRequest :members: + :noindex: .. autoclass:: interactions.api.http.emoji.EmojiRequest :members: + :noindex: .. autoclass:: interactions.api.http.guild.GuildRequest :members: + :noindex: .. autoclass:: interactions.api.http.interaction.InteractionRequest :members: + :noindex: .. autoclass:: interactions.api.http.member.MemberRequest :members: + :noindex: .. autoclass:: interactions.api.http.message.MessageRequest :members: + :noindex: .. autoclass:: interactions.api.http.reaction.ReactionRequest :members: + :noindex: .. autoclass:: interactions.api.http.scheduledEvent.ScheduledEventRequest :members: + :noindex: .. autoclass:: interactions.api.http.sticker.StickerRequest :members: + :noindex: .. autoclass:: interactions.api.http.thread.ThreadRequest :members: + :noindex: .. autoclass:: interactions.api.http.user.UserRequest :members: + :noindex: .. autoclass:: interactions.api.http.webhook.WebhookRequest :members: + :noindex: From 37f2a36f14f32951eb0d524819be2c110dd3a65e Mon Sep 17 00:00:00 2001 From: mAxYoLo01 Date: Tue, 1 Nov 2022 16:57:32 +0000 Subject: [PATCH 32/32] feat: merge all request classes docs under HTTPClient docs --- docs/api.http.rst | 49 +---------------------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-) diff --git a/docs/api.http.rst b/docs/api.http.rst index 1abccf80d..e8a99d171 100644 --- a/docs/api.http.rst +++ b/docs/api.http.rst @@ -21,52 +21,5 @@ HTTP .. autoclass:: interactions.api.http.client.HTTPClient :members: - :noindex: - -.. autoclass:: interactions.api.http.channel.ChannelRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.emoji.EmojiRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.guild.GuildRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.interaction.InteractionRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.member.MemberRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.message.MessageRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.reaction.ReactionRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.scheduledEvent.ScheduledEventRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.sticker.StickerRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.thread.ThreadRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.user.UserRequest - :members: - :noindex: - -.. autoclass:: interactions.api.http.webhook.WebhookRequest - :members: + :inherited-members: :noindex: