From ce1689d404d19551249e1eef94f01718a21b768c Mon Sep 17 00:00:00 2001 From: Luke Robles <98352913+lrobles-iterable@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:44:13 -0700 Subject: [PATCH] convert emoji to a slash command --- app/cogs/server_utils.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py index 2305ce5a..b72761f3 100644 --- a/app/cogs/server_utils.py +++ b/app/cogs/server_utils.py @@ -38,9 +38,20 @@ class ServerUtils(commands.Cog): await ctx.reply("Check your DMs") await ctx.author.send(invite) - @commands.command(name="emoji") + @commands.slash_command( + guild_ids=None, + name="emoji", + description="Upload an image to the server as an emoji", + ) + @option( + name="url", + description="The URL to an image you want to add as an emoji", + required=True, + ) + @option( + name="emoji_name", description="The name of the emoji to create", required=True + ) async def emoji(self, ctx: commands.Context, url, emoji_name): - await ctx.message.delete() import core_utils if "webp" in url: @@ -49,31 +60,23 @@ class ServerUtils(commands.Cog): emoji_staging = "/tmp/emoji" try: core_utils.download_image(url, emoji_staging) - emoji_id = await ctx.message.guild.create_custom_emoji( + emoji_id = await ctx.guild.create_custom_emoji( name=emoji_name, image=open(emoji_staging, "rb").read(), ) - await ctx.send( + await ctx.respond( embed=core_utils.generate_embed( embed_title="New emoji: %s" % emoji_name, embed_description=emoji_id, ) ) except Exception as e: - await ctx.send( + await ctx.respond( "I wasnt able to upload that image as an emoji. Sorry\n\nError: %s" % e ) os.remove(emoji_staging) return - @commands.command(name="oncall") - async def oncall(self, ctx: commands.Context): - - await ctx.invoke( - self.bot.get_command("timeout"), member=ctx.message.author, time="10s" - ) - await ctx.reply("No u") - @commands.slash_command( guild_ids=None, name="wordle",