{"id":17258892,"url":"https://github.com/beemoe5/discord-interactions-py","last_synced_at":"2026-04-30T17:31:47.245Z","repository":{"id":251561874,"uuid":"837770709","full_name":"BeeMoe5/discord-interactions-py","owner":"BeeMoe5","description":"A python port made from discord's node.js user installable application module. See https://github.com/discord/discord-interactions-js/tree/main","archived":false,"fork":false,"pushed_at":"2024-08-22T01:40:17.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T09:17:59.372Z","etag":null,"topics":["discord","discord-interactions","python3"],"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/BeeMoe5.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2024-08-04T01:29:10.000Z","updated_at":"2024-08-22T01:40:19.000Z","dependencies_parsed_at":"2024-12-04T07:24:01.763Z","dependency_job_id":"5dc07677-33c0-4d3d-90c0-be6a60148cea","html_url":"https://github.com/BeeMoe5/discord-interactions-py","commit_stats":null,"previous_names":["beemoe5/discord-interactions-py"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BeeMoe5/discord-interactions-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeeMoe5%2Fdiscord-interactions-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeeMoe5%2Fdiscord-interactions-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeeMoe5%2Fdiscord-interactions-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeeMoe5%2Fdiscord-interactions-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BeeMoe5","download_url":"https://codeload.github.com/BeeMoe5/discord-interactions-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BeeMoe5%2Fdiscord-interactions-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32472396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-interactions","python3"],"created_at":"2024-10-15T07:22:29.628Z","updated_at":"2026-04-30T17:31:47.231Z","avatar_url":"https://github.com/BeeMoe5.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# discord-interactions-py\nA python port made from discord's node.js user installable application module. See https://github.com/discord/discord-interactions-js/tree/main\n\n# Tests\nWhile the `tests` directory is me testing and random stuff, you can use it as a reference how to this tool. However, I\nwill still provide examples below\n\n# Setup\nYou'll need to make a .env file with APP_ID, APP_PUBKEY, and APP_TOKEN keys in it. You get the values from discord dev portal\n# Usage\nFirst, you'll want to set up the HTTP Middleware:\n```python\nfrom fastapi import FastAPI\nfrom starlette.middleware.base import BaseHTTPMiddleware\nfrom discord_interactions import verify_incoming_requests\n\n\napp = FastAPI()\napp.add_middleware(BaseHTTPMiddleware, dispatch=verify_incoming_requests)\n```\nWhenever a request is made to the app, `verify_incoming_requests` is called and verifies that its coming from discord.\nIf its not from discord, an error response is returned to the requester.\n\nNext, you'll want to add a GET endpoint to the app that discord will make requests to, and process the json:\n```python\nfrom fastapi import FastAPI, Request\nfrom starlette.middleware.base import BaseHTTPMiddleware\nfrom discord_interactions import verify_incoming_requests, process_commands\nfrom discord_interactions.models import InteractionType\n\n\napp = FastAPI()\napp.add_middleware(BaseHTTPMiddleware, dispatch=verify_incoming_requests)\n\n\n@app.get('/interactions')\nasync def interactions(request: Request):\n    _json = await request.json()\n    interaction_type = InteractionType(_json['type'])\n\n    if interaction_type == InteractionType.PING:  # ping\n        return {\"type\": InteractionType.PONG}  # pong\n    \n    if interaction_type == InteractionType.APPLICATION_COMMAND:  # command\n\n        response = await process_commands(_json)\n        return response\n```\nThis does 2 things, but I'll start with the first part: The first if statement checks if discord is sending a ping to\nyour app, if so then it sends a \"pong\" response back to discord. Now, for the second if statement: This checks if\na slash command was used on your app, if so then it processes the command using the `process_commands` coroutine\n\nNext, you'll want to start creating a slash command:\n```python\nfrom fastapi import FastAPI, Request\nfrom starlette.middleware.base import BaseHTTPMiddleware\nfrom discord_interactions import verify_incoming_requests, process_commands, command\nfrom discord_interactions.models import InteractionType, ContentModel\n\n\napp = FastAPI()\napp.add_middleware(BaseHTTPMiddleware, dispatch=verify_incoming_requests)\n\n\n@app.get('/interactions')\nasync def interactions(request: Request):\n    _json = await request.json()\n    interaction_type = InteractionType(_json['type'])\n\n    if interaction_type == InteractionType.PING:  # ping\n        return {\"type\": InteractionType.PONG}  # pong\n    \n    if interaction_type == InteractionType.APPLICATION_COMMAND:  # command\n\n        response = await process_commands(_json)\n        return response\n\n\n@command(name='ping')\nasync def ping(interaction):\n    \"\"\"ping pong\"\"\"\n    return ContentModel(content=\"Pong!\")\n```\nThe `@command` decorator adds the command internally, so `discord-interactions-py` handles registering and running the\ncommand. `ContentModel` is a pydantic Model, so you can create responses using python objects without using json or \ndicts. if the decorator `name` keyword isn't provided, the function name is used instead. if there isn't a docstring\nprovided, then \"No description\" is the default.\n\nIf you want to register new commands to your app, use the `register_commands` coroutine:\n```python\n@command(name='register')\nasync def register(interaction):\n    await register_commands()\n    return ContentModel(content='Commands have been registered!')\n```\nUsing `register_commands` registers and updates all commands to discord using the `@command` decorator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeemoe5%2Fdiscord-interactions-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeemoe5%2Fdiscord-interactions-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeemoe5%2Fdiscord-interactions-py/lists"}