From f66244a305fb222282db7f8a4491beb4ff820467 Mon Sep 17 00:00:00 2001 From: FrozenChen Date: Wed, 6 Nov 2024 02:21:00 -0300 Subject: [PATCH] rules.py: Send rules in batches --- cogs/rules.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cogs/rules.py b/cogs/rules.py index f646cf3a..827a9144 100644 --- a/cogs/rules.py +++ b/cogs/rules.py @@ -4,6 +4,7 @@ import json from discord.ext import commands +from itertools import batched from typing import TYPE_CHECKING from utils.checks import is_staff from utils.database.configuration import Rule @@ -124,8 +125,11 @@ async def updaterules(self, ctx: KurisuContext): async for message in channel.history(): await message.delete() await channel.send(self.rules_intro) - for number, rule in sorted(self.configuration.rules.items()): - await channel.send(embed=discord.Embed(title=f"Rule {number} - {rule.title}", description=rule.description, color=gen_color(rule.number))) + for batch in batched(self.configuration.rules.values(), 10): + embeds = [] + for rule in batch: + embeds.append(discord.Embed(title=f"Rule {rule.number} - {rule.title}", description=rule.description, color=gen_color(rule.number))) + await channel.send(embeds=embeds) await channel.send(self.staff_action) staff = [f"<@{staff}>" for staff in self.configuration.staff] await channel.send(self.mod_list + '\n'.join(staff))