Skip to content

Commit

Permalink
Merge pull request #85 from ProbablyButter/main
Browse files Browse the repository at this point in the history
fixed querying statistics when they're near empty
  • Loading branch information
makayla-moster authored Nov 28, 2024
2 parents 4e03bcb + 25a66ea commit 008f330
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cog_modules/random/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async def gizmo(self, ctx: commands.Context):
with open("gizmoResources", "wb") as f:
pickle.dump(gizmoResources, f)
most_common = gizmoResources.most_common(2)
if most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
if len(gizmoResources) >= 2 and most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
info += f" HammerBot's favorite Gizmo pic! Shown {most_common[0][1]} times."
elif gizmoResources[pic] == 1:
info += " First time shown! ^_^"
Expand All @@ -73,7 +73,7 @@ async def tao(self, ctx: commands.Context):
with open("taoResources", "wb") as f:
pickle.dump(taoResources, f)
most_common = taoResources.most_common(2)
if most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
if len(taoResources) >= 2 and most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
info += f" HammerBot's favorite Tao pic! Shown {most_common[0][1]} times."
elif taoResources[pic] == 1:
info += " First time shown! ^_^"
Expand All @@ -99,7 +99,7 @@ async def zookie(self, ctx: commands.Context):
with open("zookieResources", "wb") as f:
pickle.dump(zookieResources, f)
most_common = zookieResources.most_common(2)
if most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
if len(zookieResources) >= 2 and most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
info += f" HammerBot's favorite Zookie pic! Shown {most_common[0][1]} times."
elif zookieResources[pic] == 1:
info += " First time shown! ^_^"
Expand Down

0 comments on commit 008f330

Please sign in to comment.