Tex command: more helpful error messages (#416)

* replace error message with common mistakes
* explicitly mention document mode in docstring
* add changelog

fixes #415 

Co-authored-by: thxo <thx@uw.edu>
This commit is contained in:
thxo 2021-04-09 16:39:46 -07:00 committed by GitHub
parent 62b549619e
commit 38ba8d9d0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Added
- Helpful LaTeX hints for rendering errors in `?tex`.
## [2.7.0] - 2021-04-03

View File

@ -28,7 +28,10 @@ class TexCog(commands.Cog):
@commands.command(name="tex", aliases=["latex"], category=cmn.Cats.UTILS)
async def tex(self, ctx: commands.Context, *, expr: str):
"""Renders a LaTeX expression."""
"""Renders a LaTeX expression.
In paragraph mode by default. To render math, add `$` around math expressions.
"""
payload = {
"format": "png",
"code": self.template.replace("#CONTENT#", expr),
@ -45,7 +48,11 @@ class TexCog(commands.Cog):
if render_result["status"] != "success":
embed = cmn.embed_factory(ctx)
embed.title = "LaTeX Rendering Failed!"
embed.description = render_result.get("description", "Unknown error")
embed.description = ("Here are some common reasons:\n"
"• Did you forget to use math mode? Surround math expressions with `$`,"
" like `$x^3$`.\n"
"• Are you using a command from a package? It might not be available.\n"
"• Are you including the document headers? We already did that for you.")
embed.colour = cmn.colours.bad
await ctx.send(embed=embed)
return