diff --git a/cogs/fun.py b/cogs/fun.py index ef66c2e..306dfdd 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -69,4 +69,11 @@ async def rps_command(interaction, choice): win ]) await interaction.response.send(text) - \ No newline at end of file + +@discohook.command.slash('gtn', description = 'Guess the number! It\'s completely random every single time you run this command, so... good luck!', options=[discohook.Option.integer("num", "The number to guess", required=True, min_value=0, max_value=9999)]) +async def gtn_command(interaction, num): + number = random.randint(0,9999) + if num == number: + await interaction.response.send("Somehow, with a 1/9999 chance, you guessed the number!") + else: + await interaction.response.send(f"You didn't guess the number. Try again! The number was {number} by the way.") \ No newline at end of file diff --git a/main.py b/main.py index 904c225..ba9a363 100644 --- a/main.py +++ b/main.py @@ -8,10 +8,10 @@ import aiohttp import discohook from starlette.responses import JSONResponse from cogs.utils import ping_command -from cogs.fun import dice_command, decide_command, rps_command +from cogs.fun import dice_command, decide_command, rps_command, gtn_command def run(): - + # Lifespan can also be used to async setup .session and .db attributes # https://www.starlette.io/lifespan @contextlib.asynccontextmanager @@ -57,7 +57,8 @@ def run(): ping_command, dice_command, decide_command, - rps_command + rps_command, + gtn_command ) # Attach / route for debugging