From 080a04cb8480424cacebb7172ff89b4b3c5c233b Mon Sep 17 00:00:00 2001 From: Leander Furumo Date: Tue, 24 Sep 2024 08:13:15 +0200 Subject: [PATCH] add coinflip command --- src/cogs/misc.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/cogs/misc.py b/src/cogs/misc.py index 99829b9..4f11ec0 100644 --- a/src/cogs/misc.py +++ b/src/cogs/misc.py @@ -312,6 +312,25 @@ class Misc(commands.Cog): await interaction.response.send_message(random_link) + @app_commands.checks.cooldown(1, 2) + @app_commands.command(name="coinflip", description="Kron eller mynt?") + async def coinflip(self, interaction: discord.Interaction): + """ + Flip a coin + + Parameters + ---------- + interaction (discord.Interaction): Slash command context object + """ + + random_result = random.randint(1, 100) # We use 1 and not 0 to avoid a tie + if random_result >= 50: # And by including 50 we avoid that tie + outcome = "Kron" + elif random_result < 50: + outcome = "Mynt" + + await interaction.response.send_message(outcome) + async def setup(bot: commands.Bot): """