From 7cf5860b74c584c611b4f88d8bda014764672740 Mon Sep 17 00:00:00 2001 From: ProbablyButter Date: Fri, 15 Sep 2023 17:36:38 -0700 Subject: [PATCH] Track gizmo pics shown --- cog_modules/random/cog.py | 11 ++++++++++- resources.py | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cog_modules/random/cog.py b/cog_modules/random/cog.py index 2649162..c60f960 100644 --- a/cog_modules/random/cog.py +++ b/cog_modules/random/cog.py @@ -8,6 +8,7 @@ from dotenv import load_dotenv from gizmopics import * +from resources import gizmoResources load_dotenv() CATS = os.getenv("x-api-key") @@ -38,8 +39,16 @@ async def cat_error(self, ctx, error): @commands.cooldown(1, 30, commands.BucketType.user) async def gizmo(self, ctx: commands.Context): num = random.randint(0, len(gizmoPics) - 1) - info = f"Gizmo #{num + 1} of {len(gizmoPics)}" + info = f"Gizmo #{num + 1} of {len(gizmoPics)}." pic = gizmoPics[num] + gizmoResources[pic] += 1 + most_common = gizmoResources.most_common(1) + if pic == most_common[0][0]: + info += f" HammerBot's favorite Gizmo pic! Shown {most_common[0][1]} times." + elif gizmoResources[pic] == 1: + info += " First! ^_^" + else: + info += f"Shown {gizmoResources[pic]} times." await ctx.send(info) await ctx.send(pic) diff --git a/resources.py b/resources.py index b36dd84..faabbe3 100644 --- a/resources.py +++ b/resources.py @@ -1,3 +1,4 @@ +from collections import Counter serverResources = { "quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "-148"}, "bshammer": {"Food": "-463", "Wood": "-622", "Gold": "-388", "Stone": "1093"}, @@ -5,3 +6,4 @@ "olaf_the_shrew": {"Food": "323", "Wood": "0", "Gold": "0", "Stone": "0"}, ".harristotle": {"Food": "-1448", "Wood": "560", "Gold": "0", "Stone": "-706"}, } +gizmoResources = Counter()