Skip to content

Commit

Permalink
Make it possible to steal emojis and stickers with reply
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Sep 14, 2024
1 parent 48c0e68 commit 00194b8
Showing 1 changed file with 43 additions and 5 deletions.
48 changes: 43 additions & 5 deletions cogs/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,29 @@ async def steal(self, ctx: commands.Context, *emojis: int | str):
Use this command in the server where you want to add the emojis.
Also works with emoji ID if you don't have access to it.
You can also reply to any emoji with this command.
"""
if ctx.guild is None:
raise exceptions.CommandError("Unable to get current guild")

if not emojis:
return await util.send_command_help(ctx)
if (
ctx.message.reference
and ctx.message.reference.message_id
and isinstance(ctx.channel, (discord.Thread, discord.TextChannel))
):
reply_message = await ctx.channel.fetch_message(
ctx.message.reference.message_id
)
emojis = [
f"<:{name}:{id}>"
for name, id in util.find_custom_emojis(reply_message.content)
]
if not emojis:
raise exceptions.CommandWarning("Replied to message has no emojis")
else:
return await util.send_command_help(ctx)

for emoji in emojis:
my_emoji = self.parse_emoji(emoji)
Expand Down Expand Up @@ -786,14 +803,35 @@ async def steal(self, ctx: commands.Context, *emojis: int | str):
@commands.command(usage="<sticker>")
@commands.has_permissions(manage_emojis=True)
async def stealsticker(self, ctx: commands.Context):
"""Steal a sticker to your own server"""
"""Steal a sticker to your own server
Use this command in the server where you want to add the stickers.
You can also reply to any sticker with this command.
"""
if ctx.guild is None:
raise exceptions.CommandError("Unable to get current guild")

if not ctx.message.stickers:
await util.send_command_help(ctx)
stickers = ctx.message.stickers
if not stickers:
if (
ctx.message.reference
and ctx.message.reference.message_id
and isinstance(ctx.channel, (discord.Thread, discord.TextChannel))
):
reply_message = await ctx.channel.fetch_message(
ctx.message.reference.message_id
)
if reply_message.stickers:
stickers = reply_message.stickers
else:
raise exceptions.CommandWarning(
"Replied to message has no stickers"
)
else:
await util.send_command_help(ctx)

for sticker in ctx.message.stickers:
for sticker in stickers:
fetched_sticker = await sticker.fetch()

if not isinstance(fetched_sticker, discord.GuildSticker):
Expand Down

0 comments on commit 00194b8

Please sign in to comment.