add a command to add a bunch of custom emotes

This commit is contained in:
io mintz 2020-06-19 04:14:39 +00:00
parent c15a774a00
commit 2667ee8d43
1 changed files with 21 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import io
import logging
import operator
import posixpath
import re
import traceback
import urllib.parse
import zipfile
@ -134,6 +135,26 @@ class Emotes(commands.Cog):
message = await self.add_safe(context, name, url, context.message.author.id)
await context.send(message)
@commands.command(name='add-these')
async def add_these(self, context, *emotes):
"""Add a bunch of custom emotes."""
ran = False
# we could use *emotes: discord.PartialEmoji here but that would require spaces between each emote.
# and would fail if any arguments were not valid emotes
for match in re.finditer(utils.emote.RE_CUSTOM_EMOTE, ''.join(emotes)):
ran = True
animated, name, id = match.groups()
image_url = utils.emote.url(id, animated=animated)
async with context.typing():
message = await self.add_safe(context, name, image_url, context.author.id)
await context.send(message)
if not ran:
return await context.send('Error: no custom emotes were provided.')
await context.message.add_reaction(utils.SUCCESS_EMOJIS[True])
@classmethod
def parse_add_command_args(cls, context, args):
if context.message.attachments: