Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track gizmo pics shown #70

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading