Add Discord sharding support and related configurations
Enhance the bot's architecture by introducing sharding capabilities, allowing for better scalability and performance. Update environment files to include sharding options, and modify the bot's core logic to handle shard connections and latencies. Implement shard-specific logging and API synchronization, ensuring that only the primary shard performs certain tasks. Update API schemas and routes to reflect shard information, improving the overall status reporting and monitoring of the bot's performance across multiple shards.
This commit is contained in:
@@ -19,7 +19,7 @@ import aiohttp
|
||||
import typing
|
||||
from typing import List
|
||||
import aiosqlite
|
||||
from utils.config import OWNER_IDS, BotName
|
||||
from utils.config import OWNER_IDS, BotName, get_shard_kwargs
|
||||
from utils import getConfig, updateConfig
|
||||
from utils.Tools import setup_db
|
||||
from .Context import Context
|
||||
@@ -39,6 +39,11 @@ class Axiom(commands.AutoShardedBot):
|
||||
intents = discord.Intents.all()
|
||||
intents.presences = True
|
||||
intents.members = True
|
||||
shard_kwargs = get_shard_kwargs()
|
||||
# Allow callers to override shard settings via kwargs
|
||||
for key in ("shard_count", "shard_ids"):
|
||||
if key in kwargs:
|
||||
shard_kwargs[key] = kwargs.pop(key)
|
||||
super().__init__(command_prefix=self.get_prefix,
|
||||
case_insensitive=True,
|
||||
intents=intents,
|
||||
@@ -48,7 +53,7 @@ class Axiom(commands.AutoShardedBot):
|
||||
owner_ids=OWNER_IDS,
|
||||
allowed_mentions=discord.AllowedMentions(
|
||||
everyone=False, replied_user=False, roles=False),
|
||||
shard_count=1)
|
||||
**shard_kwargs)
|
||||
self.status_index = 0
|
||||
self.status_list = []
|
||||
self._slash_synced = False
|
||||
|
||||
Reference in New Issue
Block a user