{"id":16793696,"url":"https://github.com/grandmoff100/discordgame","last_synced_at":"2025-04-11T00:02:01.519Z","repository":{"id":57418374,"uuid":"288793992","full_name":"GrandMoff100/DiscordGame","owner":"GrandMoff100","description":"A Python Framework for Making Text and Reaction Button Based Games in Discord.","archived":false,"fork":false,"pushed_at":"2021-05-21T14:02:54.000Z","size":52,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T20:43:01.204Z","etag":null,"topics":["discord","discord-py","hacktoberfest","hacktoberfest2020","python-framework"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GrandMoff100.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-19T17:24:15.000Z","updated_at":"2024-11-16T01:38:00.000Z","dependencies_parsed_at":"2022-09-12T12:33:15.533Z","dependency_job_id":null,"html_url":"https://github.com/GrandMoff100/DiscordGame","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrandMoff100%2FDiscordGame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrandMoff100%2FDiscordGame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrandMoff100%2FDiscordGame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrandMoff100%2FDiscordGame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrandMoff100","download_url":"https://codeload.github.com/GrandMoff100/DiscordGame/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317705,"owners_count":21083528,"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":["discord","discord-py","hacktoberfest","hacktoberfest2020","python-framework"],"created_at":"2024-10-13T08:50:01.199Z","updated_at":"2025-04-11T00:02:01.464Z","avatar_url":"https://github.com/GrandMoff100.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DiscordGame\n*DiscordGame is a Python Framework for making Games \nfrom simple mini games like Tic Tac Toe \nto full-fledge Dungeon and Dragon campaigns inside Discord.*\n\n## Getting Started\n### Installation\n```shell script\n$ pip install discordgame\n```\nOr clone the repo\n\n```shell script\n$ git clone https://github.com/GrandMoff100/DiscordGame\n```\n\nand run\n```shell script\n$ python setup.py install\n```\n\n### Usage\nDiscordGame is structured like this. \nWhenever a trigger event like a reaction (called a button) or a new message is sent while a game is active, \nthose events are passed to all games that are registered to a GameHost object. \nAs you can see here with the on_text_event and on_button_event...\n```python\nimport discordgame as dg\n```\n\n\u003e Here's a couple of examples to help you get the gist of how this framework works...\n\n\u003e These examples assume you have cloned the repository and have the examples folder downloaded.\n\n\n- *A Simple MadLib made with ``discordgame``:*\n```python\nimport discord\nimport discordgame as dg\n\n\nclass MadLib(dg.Game):\n    game_name = 'MadLib'\n\n    def __init__(self, ctx):\n        # Creates a list of blanks\n        self.word_blanks = ['(blank)'] * 8\n        # Assign a MadLib string to a variable.\n        self.lib = 'The {} {}ed across the {} to get to the {} {}. It wanted to get to the {} so it could {} with a {}.'\n        # Initialize the Parent Game class with the MadLib specific values.\n        super().__init__(self.game_name, [[self.lib.format(*self.word_blanks)]], ctx=ctx, needs_text_input=True)\n\n    # Define events to be triggered on a user's message event.\n    async def on_text_event(self, player: discord.User, text: str):\n        try:\n            next_index = self.word_blanks.index('(blank)')  # Finds the left-most blank in the list.\n            self.word_blanks.pop(next_index)  # Pops that blank from the list.\n            self.word_blanks.insert(next_index, text)  # Inserts the user's word into the said blank.\n            self.stats['Blanks to Fill -\u003e'] = len([word for word in self.word_blanks if word == '(blank)'])\n            # ^^ Updates the Blanks to fill Counter.\n            await self.update_layout([[self.lib.format(*self.word_blanks)]])  # Sends the changes to discord.\n            if '(blank)' not in self.word_blanks:\n                self.stop()\n                await player.send(self.lib.format(*self.word_blanks))  # Sends the final MadLib to the channel.\n        except ValueError:  # If there's no blank in the list.\n            self.stop()\n            await player.send(self.lib.format(*self.word_blanks))  # Sends the final MadLib to the channel.\n```\n\n- *A Cool Snake Game made with ``discordgame``:*\n\nStill developing a frame based example (mostly because I'm lazy and some of the library features aren't implemented yet)\n\n- And then loading the games (see examples/example.py)\n\n```py\nfrom discordgame import GameHost\n\n# Import our example games from 2 other files in the examples directory.\nfrom .snake import Snake\nfrom .madlib import MadLib\n\nhost = GameHost('*')\n\n# Add our Games to the GameHost so users can play them.\nhost.add_game(Snake)\nhost.add_game(MadLib)\n\n# Add run the GameHost.\nhost.run(TOKEN)\n```\n\n### More Features\n\n\n## Testing and Issues\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;We welcome any new insights and issues with this framework.\nTo make an issue, head over to the issues page on our repository -\u003e https://github.com/GrandMoff100/DiscordGame and open a new issue.\nWe look forward working on fixing any bugs or issues that we might have missed.\n\n## Contribution\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;We'd love for you to Contribute! New features and optimizations are welcome! \nJust fork the Repository and make the changes and then make a pull request with your improvements.\nIf you make enough improvements, consistently we'll add you as a contributor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrandmoff100%2Fdiscordgame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrandmoff100%2Fdiscordgame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrandmoff100%2Fdiscordgame/lists"}