{"id":13458766,"url":"https://github.com/mccoderpy/discord.py-message-components","last_synced_at":"2025-03-24T16:31:06.474Z","repository":{"id":37026713,"uuid":"374101487","full_name":"mccoderpy/discord.py-message-components","owner":"mccoderpy","description":"A \"fork\" of discord.py library made by Rapptz with implementation of the Discord Message-Components \u0026 many other features by mccoderpy","archived":false,"fork":false,"pushed_at":"2024-10-03T14:28:24.000Z","size":23492,"stargazers_count":50,"open_issues_count":11,"forks_count":12,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-13T06:57:17.869Z","etag":null,"topics":["api-v10","api-wrapper","async-api-wrapper","discord","discord-api-v10","discord-api-wrapper","discord-buttons","discord-context-menus","discord-interactions","discord-modals","discord-py","discord-py-fork","discord-select-menus","discord-slash-commands","discord4py","discordpy","message-components","modals","python3","slash-commands"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mccoderpy.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["mccoderpy"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2021-06-05T11:53:16.000Z","updated_at":"2024-10-07T08:04:00.000Z","dependencies_parsed_at":"2023-10-04T04:20:45.500Z","dependency_job_id":"955835f0-6f5f-43bc-afc5-89fa87db177b","html_url":"https://github.com/mccoderpy/discord.py-message-components","commit_stats":{"total_commits":124,"total_committers":1,"mean_commits":124.0,"dds":0.0,"last_synced_commit":"fd2026969078cf15ba28fb1b761c954fb391867a"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mccoderpy%2Fdiscord.py-message-components","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mccoderpy%2Fdiscord.py-message-components/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mccoderpy%2Fdiscord.py-message-components/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mccoderpy%2Fdiscord.py-message-components/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mccoderpy","download_url":"https://codeload.github.com/mccoderpy/discord.py-message-components/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221987339,"owners_count":16912302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-v10","api-wrapper","async-api-wrapper","discord","discord-api-v10","discord-api-wrapper","discord-buttons","discord-context-menus","discord-interactions","discord-modals","discord-py","discord-py-fork","discord-select-menus","discord-slash-commands","discord4py","discordpy","message-components","modals","python3","slash-commands"],"created_at":"2024-07-31T09:00:57.036Z","updated_at":"2024-10-29T04:30:18.731Z","avatar_url":"https://github.com/mccoderpy.png","language":"Python","funding_links":["https://github.com/sponsors/mccoderpy"],"categories":["Forks and Wrappers"],"sub_categories":["Miscellaneous"],"readme":".. |flag_ua| image:: https://mccoder-py-needs.to-sleep.xyz/r/ua.png\r\n\r\n|flag_ua| Welcome to discord.py-message-components'! |flag_ua|\r\n==============================================================\r\n\r\n.. figure:: https://cdn.discordapp.com/attachments/852872100073963532/854711446767796286/discord.py-message-components.png\r\n   :name: discord.py-message-components\r\n   :align: center\r\n   :alt: Name of the Project (discord.py-message-components)\r\n   \r\n   ..\r\n   .. image:: https://discord.com/api/guilds/852871920411475968/embed.png\r\n      :target: https://discord.gg/sb69muSqsg\r\n      :alt: Discord Server Invite\r\n\r\n   .. image:: https://img.shields.io/pypi/v/discord.py-message-components.svg\r\n      :target: https://pypi.python.org/pypi/discord.py-message-components\r\n      :alt: PyPI version info\r\n\r\n   .. image:: https://img.shields.io/pypi/pyversions/discord.py-message-components.svg\r\n      :target: https://pypi.python.org/pypi/discord.py-message-components\r\n      :alt: PyPI supported Python versions\r\n\r\n   .. image:: https://static.pepy.tech/personalized-badge/discord-py-message-components?period=total\u0026units=international_system\u0026left_color=grey\u0026right_color=green\u0026left_text=Downloads\r\n      :target: https://pepy.tech/project/discord.py-message-components\r\n      :alt: Total downloads for the project\r\n\r\n   .. image:: https://readthedocs.org/projects/discordpy-message-components/badge/?version=latest\r\n      :target: https://discordpy-message-components.readthedocs.io/en/latest/\r\n      :alt: Documentation Status\r\n\r\n   A \"fork\" of `discord.py \u003chttps://pypi.org/project/discord.py/1.7.3\u003e`_ library made by `Rapptz \u003chttps://github.com/Rapptz\u003e`_ with implemation of the `Discord-Message-Components \u003chttps://discord.com/developers/docs/interactions/message-components\u003e`_ by `mccoderpy \u003chttps://github.com/mccoderpy/\u003e`_ \r\n\r\n+---------------------------------------------------------------------------------------------------------------------------------------------------+\r\n|                                                              **❗ℹIMPORTANTℹ❗**                                                                    |\r\n+===================================================================================================================================================+\r\n| This branch represents only the `PyPI \u003chttps://pypi.org\u003e`_ version of this library,                                                               |\r\n| which is currently **not up to date** due to some (private) issues                                                                                |\r\n| (as soon as we have documented the new features and the developer branch is stable enough, this will be updated).                                 |\r\n|                                                                                                                                                   |\r\n| **To get the latest version with the newest features and bug(-fixes), please take a look at the** `developer \u003c../../tree/developer\u003e`_ **branch.** |\r\n+---------------------------------------------------------------------------------------------------------------------------------------------------+\r\n\r\n**NOTE:** \r\n     This library will be further developed independently of discord.py.\r\n     New features are also implemented. It is not an extension!\r\n     The name only comes from the fact that the original purpose of the library was to add support for message components and we haven't found a better name yet. \r\n\r\n.. figure:: https://github.com/mccoderpy/discord.py-message-components/raw/main/images/rtd-logo-wordmark-light.png\r\n   :name: discord.py-message-components documentation\r\n   :alt: Link to the documentation of discord.py-message-components\r\n   :align: center\r\n   :scale: 20%\r\n   :target: https://discordpy-message-components.readthedocs.io/en/latest/\r\n   \r\n   **Read the Documentation** `here \u003chttps://discordpy-message-components.readthedocs.io/en/latest/\u003e`_\r\n\r\nYou are in need of help or want to leave feedback?\r\n__________________________________________________\r\n\r\nOpen a `issue \u003c../../issues\u003e`_/`pull request \u003c../../pulls\u003e`_, join the `support server \u003chttps://discord.gg/sb69muSqsg\u003e`_ or send me a direct message on `Discord \u003chttps://discord.com/channels/@me\u003e`_: ``mccuber04#2960``\r\n\r\nInstalling\r\n__________\r\n\r\n**Python 3.5.3 or higher is required.**\r\n\r\nThis library overwrites the original discord.py library (or any other that would be imported using `import discord`) so to be sure all will work fine\r\nfirst uninstall the original `discord.py \u003chttps://pypi.org/project/discord.py/1.7.3\u003e`_ library if it is installed:\r\n\r\n.. code:: sh\r\n\r\n    # Linux/macOS\r\n    python3 -m pip uninstall discord.py\r\n\r\n    # Windows\r\n    py -3 -m pip uninstall discord.py\r\n\r\nThen install `this library \u003chttps://pypi.org/project/discord.py-message-components\u003e`_ using:\r\n\r\n.. code:: sh\r\n\r\n    # Linux/macOS\r\n    python3 -m pip install -U discord.py-message-components\r\n\r\n    # Windows\r\n    py -3 -m pip install -U discord.py-message-components\r\n\r\n‼️To install it from the `developer branch \u003chttps://github.com/mccoderpy/discord.py-message-components/tree/developer\u003e`_ of this library which is the **most up to date** and has **fewer bugs** use:\r\n\r\n.. code:: sh\r\n    \r\n    # Linux/macOS\r\n    python3 -m pip install -U git+https://github.com/mccoderpy/discord.py-message-components.git@developer\r\n    \r\n    # Windows\r\n    py -m pip install -U git+https://github.com/mccoderpy/discord.py-message-components.git@developer \r\n\r\nOf course you nead to have git installed on your device. If you need help with this, take a look `here \u003chttps://github.com/git-guides/install-git\u003e`_\r\n\r\nExamples\r\n--------\r\n\r\nA command that sends you a message and edit it when you click a Button:\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code-block:: python\r\n\r\n    import typing\r\n    import discord\r\n    from discord.ext import commands\r\n    from discord import ActionRow, Button, ButtonStyle\r\n\r\n    client = commands.Bot(command_prefix=commands.when_mentioned_or('.!'), intents=discord.Intents.all(), case_insensitive=True)\r\n\r\n    @client.command(name='buttons', description='sends you some nice Buttons')\r\n    async def buttons(ctx: commands.Context):\r\n        components = [ActionRow(Button(label='Option Nr.1',\r\n                                       custom_id='option1',\r\n                                       emoji=\"🆒\",\r\n                                       style=ButtonStyle.green\r\n                                       ),\r\n                                Button(label='Option Nr.2',\r\n                                       custom_id='option2',\r\n                                       emoji=\"🆗\",\r\n                                       style=ButtonStyle.blurple)),\r\n                      ActionRow(Button(label='A Other Row',\r\n                                       custom_id='sec_row_1st option',\r\n                                       style=ButtonStyle.red,\r\n                                       emoji='😀'),\r\n                                Button(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',\r\n                                       label=\"This is an Link\",\r\n                                       style=ButtonStyle.url,\r\n                                       emoji='🎬'))\r\n                      ]\r\n        an_embed = discord.Embed(title='Here are some Button\\'s', description='Choose an option', color=discord.Color.random())\r\n        msg = await ctx.send(embed=an_embed, components=components)\r\n\r\n        def _check(i: discord.Interaction, b):\r\n            return i.message == msg and i.member == ctx.author\r\n\r\n        interaction, button = await client.wait_for('button_click', check=_check)\r\n        button_id = button.custom_id\r\n\r\n        # This sends the Discord-API that the interaction has been received and is being \"processed\"\r\n        await interaction.defer()\r\n        # if this is not used and you also do not edit the message within 3 seconds as described below,\r\n        # Discord will indicate that the interaction has failed.\r\n\r\n        # If you use interaction.edit instead of interaction.message.edit, you do not have to defer the interaction,\r\n        # if your response does not last longer than 3 seconds.\r\n        await interaction.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),\r\n                               components=[components[0].disable_all_buttons(), components[1].disable_all_buttons()])\r\n\r\n        # The Discord API doesn't send an event when you press a link button so we can't \"receive\" that.\r\n\r\n\r\n    client.run('You Bot-Token here')\r\n\r\n\r\nAnother more complex example where a small embed will be send; you can move a small white ⬜ with the buttons:\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code-block:: python\r\n\r\n    pointers = []\r\n\r\n\r\n    class Pointer:\r\n        def __init__(self, guild: discord.Guild):\r\n            self.guild = guild\r\n            self._possition_x = 0\r\n            self._possition_y = 0\r\n\r\n        @property\r\n        def possition_x(self):\r\n            return self._possition_x\r\n\r\n        def set_x(self, x: int):\r\n            self._possition_x += x\r\n            return self._possition_x\r\n\r\n        @property\r\n        def possition_y(self):\r\n            return self._possition_y\r\n\r\n        def set_y(self, y: int):\r\n            self._possition_y += y\r\n            return self._possition_y\r\n\r\n\r\n    def get_pointer(obj: typing.Union[discord.Guild, int]):\r\n        if isinstance(obj, discord.Guild):\r\n            for p in pointers:\r\n                if p.guild.id == obj.id:\r\n                    return p\r\n            pointers.append(Pointer(obj))\r\n            return get_pointer(obj)\r\n\r\n        elif isinstance(obj, int):\r\n            for p in pointers:\r\n                if p.guild.id == obj:\r\n                    return p\r\n            guild = client.get_guild(obj)\r\n            if guild:\r\n                pointers.append(Pointer(guild))\r\n                return get_pointer(guild)\r\n            return None\r\n\r\n\r\n    def display(x: int, y: int):\r\n        base = [\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\r\n            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\r\n        ]\r\n        base[y][x] = 1\r\n        base.reverse()\r\n        return ''.join(f\"\\n{''.join([str(base[i][w]) for w in range(len(base[i]))]).replace('0', '⬛').replace('1', '⬜')}\" for i in range(len(base)))\r\n\r\n\r\n    empty_button = discord.Button(style=discord.ButtonStyle.Secondary, label=\" \", custom_id=\"empty\", disabled=True)\r\n\r\n\r\n    def arrow_button():\r\n        return discord.Button(style=discord.ButtonStyle.Primary)\r\n\r\n\r\n    @client.command(name=\"start_game\")\r\n    async def start_game(ctx: commands.Context):\r\n        pointer: Pointer = get_pointer(ctx.guild)\r\n        await ctx.send(embed=discord.Embed(title=\"Little Game\",\r\n                                           description=display(x=0, y=0)),\r\n                       components=[discord.ActionRow(empty_button, arrow_button().set_label('↑').set_custom_id('up'), empty_button),\r\n                                   discord.ActionRow(arrow_button().update(disabled=True).set_label('←').set_custom_id('left').disable_if(pointer.possition_x \u003c= 0),\r\n                                                     arrow_button().set_label('↓').set_custom_id('down').disable_if(pointer.possition_y \u003c= 0),\r\n                                                     arrow_button().set_label('→').set_custom_id('right'))\r\n                                   ]\r\n                       )\r\n\r\n\r\n    @client.on_click()\r\n    async def up(i: discord.Interaction, button):\r\n        pointer: Pointer = get_pointer(interaction.guild)\r\n        pointer.set_y(1)\r\n        await i.edit(embed=discord.Embed(title=\"Little Game\",\r\n                                         description=display(x=pointer.possition_x, y=pointer.possition_y)),\r\n                               components=[discord.ActionRow(empty_button, arrow_button().set_label('↑').set_custom_id('up').disable_if(pointer.possition_y \u003e= 9), empty_button),\r\n                                           discord.ActionRow(arrow_button().set_label('←').set_custom_id('left').disable_if(pointer.possition_x \u003c= 0),\r\n                                                             arrow_button().set_label('↓').set_custom_id('down'),\r\n                                                             arrow_button().set_label('→').set_custom_id('right').disable_if(pointer.possition_x \u003e= 9))]\r\n                               )\r\n\r\n    @client.on_click()\r\n    async def down(i: discord.Interaction, button):\r\n        pointer: Pointer = get_pointer(interaction.guild)\r\n        pointer.set_y(-1)\r\n        await i.edit(embed=discord.Embed(title=\"Little Game\",\r\n                                              description=display(x=pointer.possition_x, y=pointer.possition_y)),\r\n                               components=[discord.ActionRow(empty_button, arrow_button().set_label('↑').set_custom_id('up'), empty_button),\r\n                                           discord.ActionRow(arrow_button().set_label('←').set_custom_id('left').disable_if(pointer.possition_x \u003c= 0),\r\n                                                             arrow_button().set_label('↓').set_custom_id('down').disable_if(pointer.possition_y \u003c= 0),\r\n                                                             arrow_button().set_label('→').set_custom_id('right').disable_if(pointer.possition_x \u003e= 9))]\r\n                               )\r\n\r\n    @client.on_click()\r\n    async def right(i: discord.Interaction, button):\r\n        pointer: Pointer = get_pointer(interaction.guild)\r\n        pointer.set_x(1)\r\n        await i.edit(embed=discord.Embed(title=\"Little Game\",\r\n                                               description=display(x=pointer.possition_x, y=pointer.possition_y)),\r\n                               components=[discord.ActionRow(empty_button, arrow_button().set_label('↑').set_custom_id('up'), empty_button),\r\n                                           discord.ActionRow(arrow_button().set_label('←').set_custom_id('left'),\r\n                                                             arrow_button().set_label('↓').set_custom_id('down'),\r\n                                                             arrow_button().set_label('→').set_custom_id('right').disable_if(pointer.possition_x \u003e= 9))]\r\n                               )\r\n\r\n    @client.on_click()\r\n    async def left(i: discord.Interaction, button):\r\n        pointer: Pointer = get_pointer(interaction.guild)\r\n        pointer.set_x(-1)\r\n        await i.edit(embed=discord.Embed(title=\"Little Game\",\r\n                                               description=display(x=pointer.possition_x, y=pointer.possition_y)),\r\n                               components=[discord.ActionRow(empty_button, arrow_button().set_label('↑').set_custom_id('up'), empty_button),\r\n                                           discord.ActionRow(arrow_button().set_label('←').set_custom_id('left').disable_if(pointer.possition_x \u003c= 0),\r\n                                                             arrow_button().set_label('↓').set_custom_id('down'),\r\n                                                             arrow_button().set_label('→').set_custom_id('right'))]\r\n                               )\r\n\r\nPlease take a look at `the documentation \u003chttps://discordpy-message-components.readthedocs.io/en/latest/\u003e`_ if you want to see more examples.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmccoderpy%2Fdiscord.py-message-components","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmccoderpy%2Fdiscord.py-message-components","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmccoderpy%2Fdiscord.py-message-components/lists"}