Skip to content

Commit

Permalink
Track gizmo pics shown
Browse files Browse the repository at this point in the history
  • Loading branch information
ProbablyButter committed Sep 16, 2023
1 parent 6f1ba25 commit 7cf5860
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cog_modules/random/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from dotenv import load_dotenv

from gizmopics import *
from resources import gizmoResources

load_dotenv()
CATS = os.getenv("x-api-key")
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions resources.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from collections import Counter

Check warning on line 1 in resources.py

View workflow job for this annotation

GitHub Actions / autocodestyle

Reformatting Needed

This file needs reformatting with black
serverResources = {
"quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "-148"},
"bshammer": {"Food": "-463", "Wood": "-622", "Gold": "-388", "Stone": "1093"},
"probablybutter": {"Food": "295", "Wood": "-2024", "Gold": "-1866", "Stone": "-2886"},
"olaf_the_shrew": {"Food": "323", "Wood": "0", "Gold": "0", "Stone": "0"},
".harristotle": {"Food": "-1448", "Wood": "560", "Gold": "0", "Stone": "-706"},
}
gizmoResources = Counter()

0 comments on commit 7cf5860

Please sign in to comment.