[fix] Emoji listing

This commit is contained in:
Zeva Rose 2024-03-04 20:03:52 -07:00
parent c8428fb231
commit c3bc03430e
2 changed files with 33 additions and 21 deletions

View file

@ -233,28 +233,40 @@ Tips will be used to pay server costs, and any excess will go to local animal sh
@slash_command(name="emotes", description="Get all emotes") @slash_command(name="emotes", description="Get all emotes")
async def _emotes(self, ctx: SlashContext) -> None: async def _emotes(self, ctx: SlashContext) -> None:
emojis = await ctx.guild.fetch_all_custom_emojis() try:
static = len([x for x in emojis if not x.animated]) emojis = sorted(
animated = len([x for x in emojis if x.animated]) await ctx.guild.fetch_all_custom_emojis(),
messages = [] key=lambda x: x.animated,
current = "" reverse=True,
for emoji in emojis:
if len(current) >= 4000:
messages.append(current)
current = ""
current += f"<{'a:' if emoji.animated else ''}{emoji.name}:{emoji.id}>"
messages += current
embeds = [
Embed(
title=f"{static} Static, {animated} Animated, {len(emojis)} Total",
description=messages[0],
color="#3498db",
) )
] static = 0
for message in messages[1:]: animated = 0
embeds.append(description=message, color="#3498db") messages = []
current = ""
for emoji in emojis:
static += not emoji.animated
animated += emoji.animated
if len(current) >= 4000:
messages.append(current)
current = ""
current += f"<{'a' if emoji.animated else ''}:{emoji.name}:{emoji.id}> "
messages.append(current)
embeds = [
Embed(
title=f"{static} Static, {animated} Animated, {len(emojis)} Total",
description=messages[0],
color="#3498db",
)
]
for message in messages[1:]:
embeds.append(Embed(description=message, color="#3498db"))
await ctx.send(embeds=embeds) message = await ctx.send(embeds=embeds[:10])
for i in range(10, len(embeds), 10):
await message.reply(embeds=embeds[i : i + 10])
except Exception as e:
self.logger.error("Encountered error: {e}", exc_info=True)
@slash_command( @slash_command(
name="roleinfo", name="roleinfo",

View file

@ -2,4 +2,4 @@
from importlib.metadata import version as _v from importlib.metadata import version as _v
__version__ = "2.5.2" __version__ = "2.5.3"