Skip to content

Commit

Permalink
[Emoji] add sticker list command
Browse files Browse the repository at this point in the history
  • Loading branch information
noahkw committed Jan 29, 2024
1 parent 7970466 commit bce98fc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cogs/EmojiUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async def setup(bot):

class EmojiUtils(commands.Cog):
SPLIT_MSG_AFTER = 15
SPLIT_STICKERS_AFTER = 3
NEW_EMOTE_THRESHOLD = 60 # in minutes
DELETE_LIMIT = 50
UPDATE_FREQUENCY = 60 # in seconds
Expand All @@ -44,6 +45,13 @@ async def _send_emoji_list(self, channel: discord.TextChannel, after=None):
for emoji_chunk in chunker(emoji_sorted, self.SPLIT_MSG_AFTER):
await channel.send(" ".join(str(e) for e in emoji_chunk))

async def _send_sticker_list(self, channel: discord.TextChannel):
stickers = channel.guild.stickers
stickers_sorted = sorted(stickers, key=lambda s: s.name)

for sticker_chunk in chunker(stickers_sorted, self.SPLIT_STICKERS_AFTER):
await channel.send(stickers=sticker_chunk)

async def _update_emoji_list(self, guild: discord.Guild):
async with self.bot.Session() as session:
try:
Expand Down Expand Up @@ -88,6 +96,20 @@ async def _download_emoji(self, emoji_url):

return await response.read()

@auto_help
@commands.group(
name="sticker",
brief="Sticker related convenience commands",
)
@commands.has_permissions(manage_emojis=True)
async def sticker(self, ctx):
if not ctx.invoked_subcommand:
await ctx.send_help(self.sticker)

@sticker.command(name="list", brief="Sends a list of the guild's stickers")
async def sticker_list(self, ctx, channel: discord.TextChannel = None):
await self._send_sticker_list(channel or ctx.channel)

@auto_help
@commands.group(
name="emoji",
Expand Down

0 comments on commit bce98fc

Please sign in to comment.