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.lib.webhook import webhook
from IntegraCord.lib.handler import InteractionHandler
from IntegraCord.lib.commands import register_global_commands
from IntegraCord.lib.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.1.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.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: integracord-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 7e3b6e7e3718be461b27569096c06a7579faf74a9d003b2d6adb47ab5edc774e
MD5 1c8b67036bc1634561e05eb1ba7237d7
BLAKE2b-256 8f66294ae02ca33a7fbb7c124cfed5d1612f1de9b6164b75d226eaf4739f2697

See more details on using hashes here.

File details

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

File metadata

  • Download URL: IntegraCord-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51687cbfe141865f64bb052e1f927fb59850e180fcdafcc19ea3ab62343c4059
MD5 ef01ed1945ca11f4f2e7af29594556fb
BLAKE2b-256 0e4661c1498cf0e98828478dcccef56f81a2920065a29107a7fb6909855cb138

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