Skip to content
Circuit edited this page Mar 1, 2022 · 4 revisions

hikari-clusters is a library that adds clustering functionality to hikari. Usage is as simple as:

# brain.py
from hikari_clusters import Brain

Brain(
    host="localhost",
    port=8765,
    token="ipc token",
    total_servers=1,
    clusters_per_server=2,
    shards_per_cluster=3,
).run()
# server.py
from hikari import GatewayBot
from hikari_clusters import Cluster, ClusterLauncher, Server

class MyBot(GatewayBot):
    cluster: Cluster

    def __init__(self):
        super().__init__(token="discord token")

        # load modules & events here

Server(
    host="localhost",
    port=8765,
    token="ipc token",
    cluster_launcher=ClusterLauncher(MyBot),
).run()

Now you can run python brain.py and python server.py to launch your bot! The configuration will launch two clusters on a single server, but you can increase the number of servers (and just run python server.py on each VPS).

Clone this wiki locally