A high-performance inter-process communication library designed to handle communication between multiple shards
This library is made to handle multiple discord clients. If you want something simpler or have only one client, check out better-ipc
python3 -m pip install -U better-cluster
py -m pip install -U better-cluster
python3 -m pip install -U git+https://github.com/MiroslavRosenov/better-cluster
py -m pip install -U git+https://github.com/MiroslavRosenov/better-cluster
You can join the support server here
import asyncio
import logging
from discord.ext.cluster import Cluster
logging.basicConfig(level=logging.INFO)
if __name__ == "__main__":
cluster = Cluster()
asyncio.run(cluster.start())
import asyncio
import discord
import logging
from discord.ext.cluster import Shard, ClientPayload
from discord.ext import commands
logging.basicConfig(level=logging.INFO)
logging.getLogger("discord.http").disabled = True
logging.getLogger("discord.client").disabled = True
logging.getLogger("discord.gateway").disabled = True
class MyBot(commands.Bot):
def __init__(self) -> None:
intents = discord.Intents.all()
super().__init__(
command_prefix="$.",
intents=intents
)
self.shard = Shard(self, shard_id=1)
async def setup_hook(self) -> None:
await self.shard.connect()
@Shard.route(shard_id=1)
async def get_user_data(self, data: ClientPayload):
user = self.get_user(data.user_id)
return user._to_minimal_user_json()
if __name__ == '__main__':
bot = MyBot()
asyncio.run(bot.run(...))
from quart import Quart
from discord.ext import cluster
app = Quart(__name__)
ipc = cluster.Client()
@app.route('/')
async def main():
return await ipc.request("get_user_data", 1, user_id=383946213629624322)
if __name__ == '__main__':
app.run(port=8000, debug=True)