Skip to content

Commit

Permalink
Merge pull request #382 from PyBotDevs/add-randomnumber-cmd
Browse files Browse the repository at this point in the history
Add `/randomnumber` command to let users choose a random number between `x` and `y`
  • Loading branch information
notsniped authored May 4, 2024
2 parents 724f56f + b40feeb commit bc4eda8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cogs/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

0 comments on commit bc4eda8

Please sign in to comment.