From a3e318d4e5ec0ac61acddea0d7e9d44d605ee69e Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 12 Jan 2020 17:32:24 +0100 Subject: [PATCH] added math --- cogs/fun/math.py | 20 ++++++++++++++++++++ cogs/help.py | 1 + 2 files changed, 21 insertions(+) create mode 100644 cogs/fun/math.py diff --git a/cogs/fun/math.py b/cogs/fun/math.py new file mode 100644 index 0000000..6c92e54 --- /dev/null +++ b/cogs/fun/math.py @@ -0,0 +1,20 @@ +import discord +from discord.ext import commands +from sympy import preview +from util import embed + +class Math(commands.Cog): + + def __init__(self, client: discord.Client): + self.client = client + + @commands.command(name="latex", description="Transforms a latex(math!) expression to an image", usage="latex ", aliases=["lat", "tex", "l"]) + @commands.cooldown(1, 5) + async def latex(self, ctx: commands.Context, *expr: str): + preview(f"$${' '.join(expr)}$$", viewer='file', filename='latex.png', euler=False) + result = embed.make_embed_image("LaTeX", "latex.png") + await ctx.send(embed=result[0], file=result[1]) + + +def setup(client: discord.Client): + client.add_cog(Math(client)) \ No newline at end of file diff --git a/cogs/help.py b/cogs/help.py index d2a28e2..257a67a 100644 --- a/cogs/help.py +++ b/cogs/help.py @@ -72,6 +72,7 @@ class Help(commands.MinimalHelpCommand): for cog, cog_commands in mapping.items(): cmds = cmds + cog_commands + cog = cog # Just so that the warning goes away newCmds = [] for item in cmds: