aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/fun/uwu.py
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2022-08-18 16:59:36 +0100
committerGravatar GitHub <[email protected]>2022-08-18 16:59:36 +0100
commite893fd6a862e1f8e7c312d876e29c98f77674cb0 (patch)
tree9478af74c5de9a55f5a8e4ba201912c10e853758 /bot/exts/fun/uwu.py
parentMerge pull request #1083 from algmyr/latex (diff)
parentAdd error handling to get_discord_message (diff)
Merge pull request #1080 from AbooMinister25/uwu-embed-fix
Fix issue with .uwu failing to uwuify embeds in replies
Diffstat (limited to 'bot/exts/fun/uwu.py')
-rw-r--r--bot/exts/fun/uwu.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/bot/exts/fun/uwu.py b/bot/exts/fun/uwu.py
index 81e81b36..83497893 100644
--- a/bot/exts/fun/uwu.py
+++ b/bot/exts/fun/uwu.py
@@ -9,10 +9,7 @@ from discord.ext import commands
from discord.ext.commands import Cog, Context, clean_content
from bot.bot import Bot
-from bot.utils import helpers
-
-if t.TYPE_CHECKING:
- from bot.exts.fun.fun import Fun # pragma: no cover
+from bot.utils import helpers, messages
WORD_REPLACE = {
"small": "smol",
@@ -169,7 +166,10 @@ class Uwu(Cog):
# If `text` isn't provided then we try to get message content of a replied message
text = text or getattr(ctx.message.reference, "resolved", None)
if isinstance(text, discord.Message):
+ embeds = text.embeds
text = text.content
+ else:
+ embeds = None
if text is None:
# If we weren't able to get the content of a replied message
@@ -177,20 +177,25 @@ class Uwu(Cog):
await clean_content(fix_channel_mentions=True).convert(ctx, text)
- fun_cog: t.Optional[Fun] = ctx.bot.get_cog("Fun")
- if fun_cog:
- text, embed = await fun_cog._get_text_and_embed(ctx, text)
-
- # Grabs the text from the embed for uwuification.
- if embed is not None:
- embed = fun_cog._convert_embed(self._uwuify, embed)
+ # Grabs the text from the embed for uwuification
+ if embeds:
+ embed = messages.convert_embed(self._uwuify, embeds[0])
else:
- embed = None
- converted_text = self._uwuify(text)
- converted_text = helpers.suppress_links(converted_text)
+ # Parse potential message links in text
+ text, embed = await messages.get_text_and_embed(ctx, text)
+
+ # If an embed is found, grab and uwuify its text
+ if embed:
+ embed = messages.convert_embed(self._uwuify, embed)
# Adds the text harvested from an embed to be put into another quote block.
- converted_text = f">>> {converted_text.lstrip('> ')}"
+ if text:
+ converted_text = self._uwuify(text)
+ converted_text = helpers.suppress_links(converted_text)
+ converted_text = f">>> {converted_text.lstrip('> ')}"
+ else:
+ converted_text = None
+
await ctx.send(content=converted_text, embed=embed)