Skip to main content

IntegraCord that allows you to connect to the application as a 'Webhook' without connecting to the Discord gateway.

Project description

IntegraCord

IntegraCord that allows you to connect to the application as a "Webhook" without connecting to the Discord gateway.

Setup

  1. Download repository pip install IntegraCord.
  2. Create an .env file for configuration and enter:
BOT_TOKEN=TOKEN # The bot token is needed for integration with the discord API, e.g. channel creation and so on
APPLICATION_ID=ID
APPLICATION_PUBLIC_KEY=KEY
  1. Create a startup file, e.g. main.py, and enter this script:
from fastapi import FastAPI, Request
from IntegraCord.webhook import webhook
from IntegraCord.handler import InteractionHandler
from IntegraCord.commands import register_global_commands
from IntegraCord.utils import send_message

import asyncio

app = FastAPI()
handler = InteractionHandler()

async def setup_commands():
    await register_global_commands(handler)

@handler.command(name="ping", description="ping pong")
async def ping_command(payload):
    return send_message('pong')

@app.post("/interactions")
async def interactions(request: Request):
    payload = await webhook.validate_request(request)

    if payload.get("type") == 1:
        return await webhook.handle_ping(payload)

    return await handler.handle_interaction(payload)

if __name__ == "__main__":
    import uvicorn
    asyncio.run(setup_commands())
    uvicorn.run(app, host="0.0.0.0", port=8000)
  1. Run and wait for the script to register the commands, and open the local network.
  2. It is necessary to give your own endpoint to the application panel on the discord website, so if you have ngrok then run the command ngrok http 0.0.0.0:8000. If you do not have one then install it.
  3. If all goes according to plan, copy the displayed link in the console from ngrok and paste it into the Interactions Endpoint URL, as in the following screenshot: image

Additional notes

The library is under development, all the points mentioned in the Setup should make your bot responsive to ngrok integrations. If you don't see the command on your own server, reset Discord (CTRL + R).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

integracord-0.1.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

IntegraCord-0.1.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file integracord-0.1.0.tar.gz.

File metadata

  • Download URL: integracord-0.1.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for integracord-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b32a164a5be02df52510774cea20c2f62da2af7397d38e724162dbb5e74a82e7
MD5 46d26b21b8617c339a705452d8b3cc19
BLAKE2b-256 f76acd0bf71e1f1dc6d193f6793a4920a7fab7b5006d9581b3552044ae87ed5e

See more details on using hashes here.

File details

Details for the file IntegraCord-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: IntegraCord-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for IntegraCord-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f367e26854ea0e86315f756ee872fb760d4dc8011bfcbd885249d281397ef7d
MD5 7d1f8880408a59ef2dac44ec508f8988
BLAKE2b-256 96098287aeb7a9c801b300afb7f7803f63776677e88a38ab9c44e63024536a0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page