added math
This commit is contained in:
parent
bd8cfa44d4
commit
a3e318d4e5
2 changed files with 21 additions and 0 deletions
20
cogs/fun/math.py
Normal file
20
cogs/fun/math.py
Normal file
|
@ -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 <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))
|
|
@ -72,6 +72,7 @@ class Help(commands.MinimalHelpCommand):
|
||||||
|
|
||||||
for cog, cog_commands in mapping.items():
|
for cog, cog_commands in mapping.items():
|
||||||
cmds = cmds + cog_commands
|
cmds = cmds + cog_commands
|
||||||
|
cog = cog # Just so that the warning goes away
|
||||||
|
|
||||||
newCmds = []
|
newCmds = []
|
||||||
for item in cmds:
|
for item in cmds:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue