Skip to content

Commit

Permalink
Adventure Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoz committed Oct 1, 2024
1 parent 6c24a32 commit c9e2ff6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cogs/palgame/adventure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from nextcord import Interaction
import random
import time
import json
import os
from utils.palgame import (
get_pals,
add_experience,
Expand All @@ -15,6 +17,11 @@ class AdventureCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.cooldowns = {}
self.pals = self.load_pals()

def load_pals(self):
with open(os.path.join('gamedata', 'game.json'), 'r') as file:
return json.load(file)

def check_cooldown(self, user_id):
if user_id in self.cooldowns:
Expand Down Expand Up @@ -42,6 +49,12 @@ async def autocomplete_pals(self, interaction: nextcord.Interaction, current: st

await interaction.response.send_autocomplete(choices=choices[:10])

def get_pal_image(self, pal_name):
for pal in self.pals:
if pal['Name'] == pal_name:
return pal.get('WikiImage')
return None

@nextcord.slash_command(name="adventure", description="Send one of your Pals on an adventure!")
@restrict_command()
async def adventure(
Expand All @@ -66,6 +79,8 @@ async def adventure(
await interaction.response.send_message("You don't have this Pal! Please select one of your own Pals.", ephemeral=True)
return

pal_image = self.get_pal_image(pal_name)

self.update_cooldown(user_id)

currency_earned = random.randint(50, 200)
Expand All @@ -85,6 +100,9 @@ async def adventure(
description=description,
color=nextcord.Color.green()
)
if pal_image:
embed.set_thumbnail(url=pal_image)

await interaction.response.send_message(embed=embed)

@adventure.on_autocomplete("pal_name")
Expand Down

0 comments on commit c9e2ff6

Please sign in to comment.