Skip to main content

An IPC extension allowing for the communication between a discord.py bot and an asynchronous web-framework.

Project description

Discord IPC

An IPC extension allowing for the communication between a discord.py bot and an asynchronous web-framework.

What is Discord IPC?

Discord IPC is a discord.py extension which allows the communication between a discord.py bot and an asynchronous web-framework. You can use the IPC extension to make a route, set some data, and have it update your command from your website - in turn updating the data of the command.

For example, updating your bot's prefix from the website.

What is Discord IPC compatible with?

Discord IPC is currently compatible with either Quart or aiohttp.web

Installation

As with other extensions, instillation is through pip

Python >=3.5.3 is required.

Linux/macOS

python3 -m pip install -U discord-ipc

Windows

py -m pip install -U discord-ipc

Examples

Client example

import discord
from discord.ext import commands, ipc
from discord.ext.ipc.server import Server
from discord.ext.ipc.objects import ClientPayload

class Bot(commands.Bot):
    def __init__(self) -> None:
        intents = discord.Intents.all()

        super().__init__(
            command_prefix="$",
            intents=intents,
        )

        self.ipc = ipc.Server(self, secret_key="my_secret_key")  # create our IPC Server

    async def setup_hook(self) -> None:
        await self.ipc.start()

    @Server.route()
    async def get_user_data(self, data: ClientPayload) -> Dict:
        user = self.get_user(data.user_id)
        return user._to_mimimal_user_json()

await self.start('token')

You can find more examples in the examples directory.

Support

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

discord-ipc-0.0.4.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

discord_ipc-0.0.4-py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 3

Supported by

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