Discord IPC
An IPC extension allowing for the communication between a discord.py bot and an asynchronous web-framework.
discord-ext-ipct project.
This project is a fork of the now unmaintainedWhat 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. It is not recommended to install through git, as this is the development branch and breaking changes may occour.
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
class MyBot(commands.Bot):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.ipc = ipc.Server(self, secret_key="my_secret_key") # create our IPC Server
async def on_ipc_ready(self):
"""Called upon the IPC Server being ready"""
print("IPC is ready.")
async def on_ipc_error(self, endpoint, error):
"""Called upon an error being raised within an IPC route"""
print(endpoint, "raised", error)
async def setup_hook(self) -> None:
await self.ipc.start()
print("Bot is online.")
my_bot = MyBot(command_prefix="!", intents=discord.Intents.all())
@my_bot.ipc.route()
async def get_member_count(data):
guild = my_bot.get_guild(data.guild_id) # get the guild object using parsed guild_id
return guild.member_count # return the member count to the client
await my_bot.ipc.start()
await my_bot.start('token')
You can find more examples in the examples directory.