diff --git a/uqcsbot/latex.py b/uqcsbot/latex.py
index 0276668..aebb492 100644
--- a/uqcsbot/latex.py
+++ b/uqcsbot/latex.py
@@ -12,14 +12,20 @@ def __init__(self, bot: commands.Bot):
@app_commands.command(description="Renders the given LaTeX")
@app_commands.describe(input="LaTeX to render")
async def latex(self, interaction: discord.Interaction, input: str):
- if len(input) == 0:
- return
+ # since bot prohibits empty prompts, checking len==0 seems redundant
+ await interaction.response.defer(thinking=True)
- url = f"https://latex.codecogs.com/png.image?%5Cdpi%7B200%7D%5Cbg%7B36393f%7D%5Cfg%7Bwhite%7D{quote(input)}"
-
- await interaction.response.send_message(
- f'LaTeX render for "{input}"\n{url}',
+ url = (
+ "https://latex.codecogs.com/png.image?"
+ "%5Cdpi%7B200%7D%5Cbg%7B36393f%7D%5Cfg%7Bwhite%7D"
+ f"{quote(input)}"
)
+ embed = discord.Embed(
+ colour=discord.Colour.blue(),
+ title=f'Latex render for "{input}"',
+ ).set_image(url=f"{url}")
+
+ await interaction.edit_original_response(embed=embed)
async def setup(bot: commands.Bot):
diff --git a/uqcsbot/voteythumbs.py b/uqcsbot/voteythumbs.py
index 9c6a4b6..d0d6894 100644
--- a/uqcsbot/voteythumbs.py
+++ b/uqcsbot/voteythumbs.py
@@ -30,8 +30,10 @@ async def voteythumbs_context(
self, interaction: discord.Interaction, message: discord.Message
):
"""Starts a 👍 👎 vote."""
+ await interaction.response.defer(ephemeral=True)
+
await self.common_react(message)
- await interaction.response.send_message("Vote away!", ephemeral=True)
+ await interaction.edit_original_response(content="Vote away!")
@app_commands.command(name="voteythumbs")
@app_commands.describe(question="The question that shall be voted upon")
@@ -39,11 +41,13 @@ async def voteythumbs_command(
self, interaction: discord.Interaction, question: str
):
"""Starts a 👍 👎 vote."""
- await interaction.response.send_message(question)
+ await interaction.response.defer()
message = await interaction.original_response()
await self.common_react(message)
+ await interaction.edit_original_response(content=question)
+
async def setup(bot: commands.Bot):
await bot.add_cog(VoteyThumbs(bot))
diff --git a/uqcsbot/xkcd.py b/uqcsbot/xkcd.py
index f77cc50..7e927ff 100644
--- a/uqcsbot/xkcd.py
+++ b/uqcsbot/xkcd.py
@@ -30,11 +30,12 @@ async def xkcd_command(
"""
Returns a random xkcd comic or the comic with the given number.
"""
+ await interaction.response.defer(thinking=True)
# If number is given, check if its a valid number
if number is not None and number <= 0:
- await interaction.response.send_message(
- "Invalid xkcd number (must be positive)"
+ await interaction.edit_original_response(
+ content="Invalid xkcd number (must be positive)"
)
return
@@ -50,10 +51,14 @@ async def xkcd_command(
# Check if the xkcd data failed to fetch
if xkcd_num == XKCD_FETCH_ERROR[0]:
- await interaction.response.send_message("Failed to fetch xkcd page")
+ await interaction.edit_original_response(
+ content="Failed to fetch xkcd page"
+ )
return
elif xkcd_num == XKCD_PARSE_ERROR[0]:
- await interaction.response.send_message("Failed to parse xkcd page data")
+ await interaction.edit_original_response(
+ content="Failed to parse xkcd page data"
+ )
return
# Create a custom embed for the xkcd comic
@@ -65,7 +70,7 @@ async def xkcd_command(
message.set_footer(text="xkcd.com")
# Send it!
- await interaction.response.send_message(embed=message)
+ await interaction.edit_original_response(embed=message)
@staticmethod
def get_xkcd_data(url: str) -> (int, str, str, str):
@@ -73,7 +78,8 @@ def get_xkcd_data(url: str) -> (int, str, str, str):
Returns the xkcd data from the given url.
:param url: The url to fetch the xkcd data from
- :return: A tuple containing the xkcd number, title, description and image url
+ :return: A tuple containing the xkcd number, title,
+ description and image url
"""
# Get the xkcd page
@@ -101,7 +107,11 @@ def parse_xkcd_page(content: str) -> (int, str, str, str):
re.MULTILINE,
)
img_match = re.search(
- r'(?<=Image URL \(for hotlinking\/embedding\): )', data
+ (
+ r'(?<=Image URL \(for hotlinking\/embedding\): )'
+ ),
+ data,
)
# If any of the regexes failed, return an error