Skip to content

Commit

Permalink
Merge pull request #74 from ProbablyButter/main
Browse files Browse the repository at this point in the history
Properly rigged HammerBot's favorite Gizmo pic
  • Loading branch information
makayla-moster authored Oct 1, 2023
2 parents 45a0598 + 27f18b3 commit ef5d4ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
5 changes: 3 additions & 2 deletions cog_modules/random/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pickle
import random
import datetime

import discord
import requests
Expand Down Expand Up @@ -45,8 +46,8 @@ async def gizmo(self, ctx: commands.Context):
gizmoResources[pic] += 1
with open("gizmoResources", "wb") as f:
pickle.dump(gizmoResources, f)
most_common = gizmoResources.most_common(1)
if pic == most_common[0][0]:
most_common = gizmoResources.most_common(2)
if 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 Down
4 changes: 4 additions & 0 deletions cog_modules/taunts/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ async def stockpile(self, ctx: commands.Context):
)
else:
serverResources[user] = {"Food": "0", "Wood": "0", "Gold": "0", "Stone": "0"}
with open("serverResources", "wb") as f:
pickle.dump(serverResources, f)
embed = discord.Embed(
title=f"{ctx.message.author.display_name}'s Resource Stockpile",
description=f"The amount of resources HammerBot has gifted you.",
Expand Down Expand Up @@ -160,6 +162,8 @@ async def no_38(self, ctx: commands.Context):
else:
serverResources[user] = {"Food": "0", "Wood": "0", "Gold": "0", "Stone": "0"}
serverResources[user][res] = str(num)
with open("serverResources", "wb") as f:
pickle.dump(serverResources, f)
await ctx.send(response)

@no_38.error
Expand Down
2 changes: 1 addition & 1 deletion gizmopics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"https://cdn.discordapp.com/attachments/1105932220838989834/1105937238124154911/IMG_2434.jpg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105932514851307530/IMG_2420.jpeg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105932515291701278/IMG_2413.jpeg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105938814515548220/IMG_1758.jpg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105939040756301864/IMG_1758.jpg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105939038642372608/70537439627__C6FD10EC-06A5-47DD-83DC-1573F2EECA1E.jpg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105939040756301864/IMG_1758.jpg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105939045466521600/IMG_1748.jpg",
Expand Down
19 changes: 12 additions & 7 deletions resources.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import pickle
from collections import Counter

serverResources = {
"quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "12"},
"bshammer": {"Food": "-1250", "Wood": "-1173", "Gold": "-850", "Stone": "1942"},
"probablybutter": {"Food": "295", "Wood": "-2024", "Gold": "-1006", "Stone": "-2044"},
"olaf_the_shrew": {"Food": "323", "Wood": "0", "Gold": "0", "Stone": "0"},
".harristotle": {"Food": "-2241", "Wood": "560", "Gold": "-986", "Stone": "-706"},
}
try:
with open("serverResources", "rb") as f:
serverResources = pickle.load(f)
except FileNotFoundError:
serverResources = {
"quela": {"Food": "-1068", "Wood": "449", "Gold": "-826", "Stone": "12"},
"bshammer": {"Food": "-1250", "Wood": "-1173", "Gold": "-850", "Stone": "1942"},
"probablybutter": {"Food": "295", "Wood": "-2024", "Gold": "-1006", "Stone": "-2044"},
"olaf_the_shrew": {"Food": "323", "Wood": "0", "Gold": "0", "Stone": "0"},
".harristotle": {"Food": "-2241", "Wood": "560", "Gold": "-986", "Stone": "-706"},
}

try:
with open("gizmoResources", "rb") as f:
gizmoResources = pickle.load(f)
Expand Down

0 comments on commit ef5d4ba

Please sign in to comment.