From 08d4d89b473f24571a3e2e51c16eb5c4e2c2320d Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 7 Jan 2023 16:30:41 +0530 Subject: [PATCH 1/2] Move all maths area commands to `SlashCommandGroup` in maths cog --- cogs/maths.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cogs/maths.py b/cogs/maths.py index 994b131c..6febeaa7 100644 --- a/cogs/maths.py +++ b/cogs/maths.py @@ -11,6 +11,8 @@ class Maths(commands.Cog): def __init__(self, bot): self.bot = bot + area = commands.SlashCommandGroup("area", "Find area of different figures.") + @commands.slash_command( name="squareroot", description="Finds the square root of any positive number" @@ -26,8 +28,8 @@ async def squareroot(self, ctx: ApplicationContext, number: int): localembed.set_footer(text=f"√({number}) = {result}") await ctx.respond(embed=localembed) - @commands.slash_command( - name="area_square", + @area.slash_command( + name="square", description="Finds the area of a square" ) @option(name="length", description="What is the length of one side?", type=int) @@ -38,8 +40,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) - @commands.slash_command( - name="area_rectangle", + @area.slash_command( + name="rectangle", description="Finds the area of a rectangle" ) @option(name="length", description="What is the length?", type=int) @@ -52,8 +54,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) - @commands.slash_command( - name="area_circle", + @area.slash_command( + name="circle", description="Finds the area of a circle" ) @option(name="radius", description="What is the radius of the circle?", type=int) @@ -64,8 +66,8 @@ async def area_circle(self, ctx: ApplicationContext, radius: int): localembed.set_footer(text=f"Taking π as 22/7\nA = πr²\nπ x {radius}² = {result} sq. units") await ctx.respond(embed=localembed) - @commands.slash_command( - name="area_triangle", + @area.slash_command( + name="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 6a14f2bb2b654799050730b2c74f40d1e3a80044 Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 7 Jan 2023 16:40:32 +0530 Subject: [PATCH 2/2] Fix command names in commands db to adjust to new slash command groups --- config/commands.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/commands.json b/config/commands.json index a514f78a..501754c4 100644 --- a/config/commands.json +++ b/config/commands.json @@ -569,7 +569,7 @@ "disabled": false, "bugged": false }, - "area_square": { + "area square": { "name": "Square Area ", "description": "Finds the area of a square.", "type": "maths", @@ -579,7 +579,7 @@ "disabled": false, "bugged": false }, - "area_rectangle": { + "area rectangle": { "name": "Rectangle Area", "description": "Finds the area of a rectangle.", "type": "maths", @@ -589,7 +589,7 @@ "disabled": false, "bugged": false }, - "area_circle": { + "area circle": { "name": "Circle Area", "description": "Finds the area of a circle. (Takes π as 22/7)", "type": "maths", @@ -599,7 +599,7 @@ "disabled": false, "bugged": false }, - "area_triangle": { + "area triangle": { "name": "Triangle Area", "description": "Finds the area of a triangle. (Uses Heron's formula)", "type": "maths",