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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for discord_ipc-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88472d9209566f5c3e26946893e43b1fc1e05d21092f734962a19a919bcab392 |
|
MD5 | d8bfc4b83b359e3834ce2a04b18e8055 |
|
BLAKE2b-256 | a4e65f4fde76aa1a365e75dc658adcb71f4f5ba949a8696031a6f23d6c571ff2 |