convert emoji to a slash command
This commit is contained in:
parent
5321de9231
commit
ce1689d404
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user