1
0
Fork 0
mirror of https://github.com/uhIgnacio/EmoteManager.git synced 2024-08-15 02:23:13 +00:00

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

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: