From ef71c99363101177c4ae034a471e2ecc74e44f9c Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:41:51 +0530 Subject: [PATCH 1/2] Rename `area` slash command group to `math` This makes the implementation of new and different types of math commands easier, and also makes finding these commands easier in isobot. --- cogs/maths.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cogs/maths.py b/cogs/maths.py index b8fea1c7..c79e9f4f 100644 --- a/cogs/maths.py +++ b/cogs/maths.py @@ -14,7 +14,7 @@ class Maths(commands.Cog): def __init__(self, bot): self.bot = bot - area = SlashCommandGroup("area", "Find area of different figures.") + math = SlashCommandGroup("math", "Use various math tools.") @commands.slash_command( name="squareroot", @@ -31,8 +31,8 @@ async def squareroot(self, ctx: ApplicationContext, number: int): localembed.set_footer(text=f"√({number}) = {result}") await ctx.respond(embed=localembed) - @area.command( - name="square", + @math.command( + name="area_square", description="Finds the area of a square" ) @option(name="length", description="What is the length of one side?", type=int) @@ -43,8 +43,8 @@ async def area_square(self, ctx: ApplicationContext, length: int): localembed.set_footer(text=f"A = s²\n{length} x {length} = {result} sq. units") await ctx.respond(embed=localembed) - @area.command( - name="rectangle", + @math.command( + name="area_rectangle", description="Finds the area of a rectangle" ) @option(name="length", description="What is the length?", type=int) @@ -57,8 +57,8 @@ async def area_rectangle(self, ctx: ApplicationContext, length: int, breadth: in localembed.set_footer(text=f"A = l x b\n{length} x {breadth} = {result} sq. units") await ctx.respond(embed=localembed) - @area.command( - name="circle", + @math.command( + name="area_circle", description="Finds the area of a circle" ) @option(name="radius", description="What is the radius of the circle?", type=int) @@ -74,8 +74,8 @@ async def area_circle(self, ctx: ApplicationContext, radius: int, pi: str = "22/ elif pi == "3":localembed.set_footer(text=f"Taking π as 3\nA = πr²\nπ x {radius}² = {result} sq. units") await ctx.respond(embed=localembed) - @area.command( - name="triangle", + @math.command( + name="area_triangle", description="Finds the area of a triangle (using Heron's formula)" ) @option(name="side_length_a", description="What is the length of side A of the triangle?", type=int) From 5177db47c01170cbd06b4a9a5dd88422a10c4f27 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:43:36 +0530 Subject: [PATCH 2/2] Remove trailing whitespaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PyCharm's honest reaction to trailing whitespaces: 👹 --- cogs/maths.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cogs/maths.py b/cogs/maths.py index c79e9f4f..f4b5cfc2 100644 --- a/cogs/maths.py +++ b/cogs/maths.py @@ -13,7 +13,7 @@ # Commands class Maths(commands.Cog): def __init__(self, bot): self.bot = bot - + math = SlashCommandGroup("math", "Use various math tools.") @commands.slash_command( @@ -30,7 +30,7 @@ async def squareroot(self, ctx: ApplicationContext, number: int): localembed = discord.Embed(title=f"Square root of {number}", description=result, color=color) localembed.set_footer(text=f"√({number}) = {result}") await ctx.respond(embed=localembed) - + @math.command( name="area_square", description="Finds the area of a square" @@ -42,7 +42,7 @@ async def area_square(self, ctx: ApplicationContext, length: int): localembed = discord.Embed(title=f"Area of square of side {length} units", description=f"{result} sq. units", color=color) localembed.set_footer(text=f"A = s²\n{length} x {length} = {result} sq. units") await ctx.respond(embed=localembed) - + @math.command( name="area_rectangle", description="Finds the area of a rectangle" @@ -73,7 +73,7 @@ async def area_circle(self, ctx: ApplicationContext, radius: int, pi: str = "22/ elif pi == "3.14": localembed.set_footer(text=f"Taking π as 3.14\nA = πr²\nπ x {radius}² = {result} sq. units") elif pi == "3":localembed.set_footer(text=f"Taking π as 3\nA = πr²\nπ x {radius}² = {result} sq. units") await ctx.respond(embed=localembed) - + @math.command( name="area_triangle", description="Finds the area of a triangle (using Heron's formula)"