mirror of
https://github.com/uhIgnacio/EmoteManager.git
synced 2024-08-15 02:23:13 +00:00
add/remove: require at least one emote, and allow more
This commit is contained in:
parent
0b731ed0fc
commit
c53f60f0d3
1 changed files with 12 additions and 11 deletions
|
@ -81,11 +81,7 @@ class Emotes:
|
||||||
`add` will upload a new emote using the first attachment as the image,
|
`add` will upload a new emote using the first attachment as the image,
|
||||||
and its filename as the name
|
and its filename as the name
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
name, url = self.parse_add_command_args(context, args)
|
name, url = self.parse_add_command_args(context, args)
|
||||||
except commands.BadArgument as exception:
|
|
||||||
return await context.send(exception)
|
|
||||||
|
|
||||||
async with context.typing():
|
async with context.typing():
|
||||||
message = await self.add_safe(context.guild, name, url, context.message.author.id)
|
message = await self.add_safe(context.guild, name, url, context.message.author.id)
|
||||||
await context.send(message)
|
await context.send(message)
|
||||||
|
@ -133,12 +129,17 @@ class Emotes:
|
||||||
return name, url
|
return name, url
|
||||||
|
|
||||||
@commands.command(name='add-from-ec', aliases=['addfromec'])
|
@commands.command(name='add-from-ec', aliases=['addfromec'])
|
||||||
async def add_from_ec(self, context, name):
|
async def add_from_ec(self, context, name, *names):
|
||||||
"""Copies an emote from Emote Collector to your server.
|
"""Copies one or more emotes from Emote Collector to your server.
|
||||||
|
|
||||||
The list of possible emotes you can copy is here:
|
The list of possible emotes you can copy is here:
|
||||||
https://emote-collector.python-for.life/list
|
https://emote-collector.python-for.life/list
|
||||||
"""
|
"""
|
||||||
|
if names:
|
||||||
|
for name in (name,) + names:
|
||||||
|
await context.invoke(self.add_from_ec, name)
|
||||||
|
return
|
||||||
|
|
||||||
name = name.strip(':')
|
name = name.strip(':')
|
||||||
try:
|
try:
|
||||||
emote = await self.aioec.emote(name)
|
emote = await self.aioec.emote(name)
|
||||||
|
@ -207,17 +208,17 @@ class Emotes:
|
||||||
reason=reason)
|
reason=reason)
|
||||||
|
|
||||||
@commands.command(aliases=('delete', 'delet', 'rm'))
|
@commands.command(aliases=('delete', 'delet', 'rm'))
|
||||||
async def remove(self, context, *emotes):
|
async def remove(self, context, emote, *emotes):
|
||||||
"""Remove an emote from this server.
|
"""Remove an emote from this server.
|
||||||
|
|
||||||
emotes: the name of an emote or of one or more emotes you'd like to remove.
|
emotes: the name of an emote or of one or more emotes you'd like to remove.
|
||||||
"""
|
"""
|
||||||
if len(emotes) == 1:
|
if not emotes:
|
||||||
emote = await self.parse_emote(context, emotes[0])
|
emote = await self.parse_emote(context, emote)
|
||||||
await emote.delete(reason=f'Removed by {utils.format_user(self.bot, context.author.id)}')
|
await emote.delete(reason=f'Removed by {utils.format_user(self.bot, context.author.id)}')
|
||||||
await context.send(f'Emote \:{emote.name}: successfully removed.')
|
await context.send(f'Emote \:{emote.name}: successfully removed.')
|
||||||
else:
|
else:
|
||||||
for emote in emotes:
|
for emote in (emote,) + emotes:
|
||||||
await context.invoke(self.remove, emote)
|
await context.invoke(self.remove, emote)
|
||||||
with contextlib.suppress(discord.HTTPException):
|
with contextlib.suppress(discord.HTTPException):
|
||||||
await context.message.add_reaction(utils.SUCCESS_EMOJIS[True])
|
await context.message.add_reaction(utils.SUCCESS_EMOJIS[True])
|
||||||
|
|
Loading…
Reference in a new issue