Browse Source

Emoji converter should now work with partial emojis. User converter renamed along with emoji converter to be less redundant.

tags/v2.0.0
Roxie Gibson 5 years ago
parent
commit
00d24675b2
3 changed files with 12 additions and 11 deletions
  1. +4
    -4
      roxbot/cogs/admin.py
  2. +4
    -3
      roxbot/cogs/util.py
  3. +4
    -4
      roxbot/converters.py

+ 4
- 4
roxbot/cogs/admin.py View File

@@ -108,7 +108,7 @@ class Admin:
@commands.bot_has_permissions(manage_messages=True, read_message_history=True)
@commands.cooldown(1, 5)
@commands.command()
async def purge(self, ctx, limit=0, *, author: roxbot.converters.UserConverter=None):
async def purge(self, ctx, limit=0, *, author: roxbot.converters.User=None):
"""Purges messages from the text channel.
Limit = Limit of messages to be deleted
Author (optional) = If given, roxbot will selectively only delete this user's messages."""
@@ -155,7 +155,7 @@ class Admin:
return await ctx.send("Reported {}.".format(str(user)))

@warn.command()
async def list(self, ctx, *, user: roxbot.converters.UserConverter=None):
async def list(self, ctx, *, user: roxbot.converters.User=None):
"""Lists all or just the warnings for one user."""
settings = gs.get(ctx.guild)

@@ -202,7 +202,7 @@ class Admin:
return await ctx.send(embed=em)

@warn.command()
async def remove(self, ctx, user: roxbot.converters.UserConverter=None, index=None):
async def remove(self, ctx, user: roxbot.converters.User=None, index=None):
"""Removes one or all of the warnings for a user."""
user_id = str(user.id)
settings = gs.get(ctx.guild)
@@ -279,7 +279,7 @@ class Admin:
@commands.has_permissions(ban_members=True)
@commands.bot_has_permissions(ban_members=True)
@commands.command()
async def unban(self, ctx, member: roxbot.converters.UserConverter, *, reason=""):
async def unban(self, ctx, member: roxbot.converters.User, *, reason=""):
"""Unbans user with given ID. Allows you to give a reason."""
ban = await ctx.guild.get_ban(member)
mem = ban.user

+ 4
- 3
roxbot/cogs/util.py View File

@@ -201,7 +201,7 @@ class Util():
return await ctx.send("File couldn't be uploaded.")

@commands.command(aliases=["emoji"])
async def emote(self, ctx, emote: roxbot.converters.EmojiConverter):
async def emote(self, ctx, emote: roxbot.converters.Emoji):
"""
Uploads the emote given. Useful for downloading emotes.
Usage:
@@ -219,8 +219,9 @@ class Util():
else:
em = discord.Embed(title=emote.name, colour=roxbot.EmbedColours.blue)
em.add_field(name="ID", value=str(emote.id), inline=False)
em.add_field(name="Guild", value=str(emote.guild), inline=False)
em.add_field(name="Created At", value="{:%a %Y/%m/%d %H:%M:%S} UTC".format(emote.created_at), inline=False)
if isinstance(emote, discord.Emoji):
em.add_field(name="Guild", value=str(emote.guild), inline=False)
em.add_field(name="Created At", value=roxbot.datetime_formatting.format(emote.created_at), inline=False)
em.set_image(url=emote.url)
return await ctx.send(embed=em)
except IndexError:

+ 4
- 4
roxbot/converters.py View File

@@ -28,7 +28,7 @@ SOFTWARE.
from discord.ext import commands


class UserConverter(commands.UserConverter):
class User(commands.UserConverter):
"""Overriding the discord version to add a slower global look up for when it is a requirement to return a user who has left the guild.

Converts to a :class:`User`.
@@ -55,14 +55,14 @@ class UserConverter(commands.UserConverter):
return result


class EmojiConverter(commands.EmojiConverter):
class Emoji(commands.EmojiConverter):
"""The Emoji conveter from discord.py but instead it returns the argument if an error is raised
It's messier than using the EmojiConverter proper but the issue is you can try converters."""
async def convert(self, ctx, argument):
try:
return await super().convert(ctx, argument)
except: # Same as above
return argument
except commands.errors.BadArgument:
return await commands.PartialEmojiConverter().convert(ctx, argument)


class AvatarURL(commands.UserConverter):

Loading…
Cancel
Save