Skip to content
Open
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
28 changes: 27 additions & 1 deletion cog_modules/random/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from dotenv import load_dotenv

from gizmopics import *
from resources import gizmoResources, taoResources, zookieResources
from resources import gizmoResources, taoResources, zookieResources, gadgetResources

load_dotenv()
CATS = os.getenv("x-api-key")
Expand Down Expand Up @@ -115,6 +115,32 @@ async def zookie_error(self, ctx, error):
f"Zookie likes to hide, so you can only view him once every 30 seconds. Try again in {round(error.retry_after, 2)} seconds."
)

@commands.command(name="!gadget")
@commands.cooldown(1, 30, commands.BucketType.user)
async def gadget(self, ctx: commands.Context):
num = random.randint(0, len(gadgetPics) - 1)
info = f"Gadget #{num + 1} of {len(gadgetPics)}."
pic = gadgetPics[num]
gadgetResources[pic] += 1
with open("gadgetResources", "wb") as f:
pickle.dump(gadgetResources, f)
most_common = gadgetResources.most_common(2)
if len(gadgetResources) >= 2 and most_common[0][1] != most_common[1][1] and pic == most_common[0][0]:
info += f" HammerBot's favorite Gadget pic! Shown {most_common[0][1]} times."
elif gadgetResources[pic] == 1:
info += " First time shown! ^_^"
else:
info += f" Shown {gadgetResources[pic]} times."
await ctx.send(info)
await ctx.send(pic)

@gadget.error
async def gadget_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(
f"Gadget likes to hide, so you can only view him once every 30 seconds. Try again in {round(error.retry_after, 2)} seconds."
)

@commands.command(name="?gizmo", aliases=["?tao"])
@commands.cooldown(1, 30, commands.BucketType.user)
async def gizmo_or_tao(self, ctx: commands.Context):
Expand Down
3 changes: 3 additions & 0 deletions gizmopics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
gizmoPics = [
"https://cdn.discordapp.com/attachments/1105932220838989834/1105932512691241112/IMG_2448.jpeg",
"https://cdn.discordapp.com/attachments/1105932220838989834/1105932513181966376/IMG_2437.jpeg",
Expand Down Expand Up @@ -573,3 +573,6 @@
"https://cdn.discordapp.com/attachments/1310771971419803668/1310772596937064488/IMG_5084.jpg?ex=674869dc&is=6747185c&hm=6af989ff24a9ada8146988bbc9aa6d181c0f196bbdb16b394c7528a5d59c5b63&",
"https://cdn.discordapp.com/attachments/1310771971419803668/1310772591518285835/560B1820-E454-411D-8449-7B5BAC079E57.jpg?ex=674869da&is=6747185a&hm=a980f700243a91110e313c59a8e2100d97e212bf2c4f364d49463ea6ba8f07a0&",
]

gadgetPics = [
]
6 changes: 6 additions & 0 deletions resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
zookieResources = pickle.load(f)
except FileNotFoundError:
zookieResources = Counter()

try:
with open("gadgetResources", "rb") as f:
gadgetResources = pickle.load(f)
except FileNotFoundError:
gadgetResources = Counter()
Loading