From b40feeb9464ff4ea1adda6e0477b825b5567a27a Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 4 May 2024 19:04:46 +0530 Subject: [PATCH] Add `/randomnumber` command to let users choose a random number between `x` and `y` `x` is the minimum limit, and `y` is the maximum limit for the random number. --- cogs/fun.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cogs/fun.py b/cogs/fun.py index 86c0276..a005f10 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -71,6 +71,18 @@ async def hackertext(self, ctx: ApplicationContext, text: str): text = text.replace("u", "x") text = text.replace("t", "7") await ctx.respond(text) + + @commands.slash_command( + name="randomnumber", + description="Choose a random number from x to y." + ) + @option(name="x", description="The minimum limit of the random number.", type=int) + @option(name="y", description="The maximum limit of the random number.", type=int) + async def randomnumber(self, ctx: ApplicationContext, x: int, y: int): + """Choose a random number from x to y.""" + if x > y: + return await ctx.respond(":x: Your minimum limit needs to be lower than the maximum limit!", ephemeral=True) + await ctx.respond(f"Your random number is `{random.randint(x, y)}`\n\nMinimum limit: `{x}`\nMaximum limit: `{y}`") # Initialization def setup(bot): bot.add_cog(Fun(bot))