Skip to content

Commit

Permalink
rules.py: Send rules in batches
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenChen committed Nov 6, 2024
1 parent a67f597 commit f66244a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cogs/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit f66244a

Please sign in to comment.