diff --git a/cog_modules/random/cog.py b/cog_modules/random/cog.py index 5544166..76f03b5 100644 --- a/cog_modules/random/cog.py +++ b/cog_modules/random/cog.py @@ -2,6 +2,7 @@ import os import pickle import random +import datetime import discord import requests @@ -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! ^_^" diff --git a/cog_modules/taunts/cog.py b/cog_modules/taunts/cog.py index 2c6d1fb..c5bff9a 100644 --- a/cog_modules/taunts/cog.py +++ b/cog_modules/taunts/cog.py @@ -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.", @@ -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 diff --git a/gizmopics.py b/gizmopics.py index 3e7a08b..ff33d67 100644 --- a/gizmopics.py +++ b/gizmopics.py @@ -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", diff --git a/resources.py b/resources.py index 3e9f12b..744a933 100644 --- a/resources.py +++ b/resources.py @@ -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)