Skip to content

Commit

Permalink
persistent data with docker volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulsender committed Jun 6, 2024
1 parent 91e1d69 commit aeb63d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cogs/leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

# get path name for csv file
file_path = os.path.join(os.getcwd(), "data")
file_path = os.path.join(file_path, "")
csv_file = "data.csv"
file_path = os.path.join(file_path, csv_file)
print(file_path)

class Leaderboard(commands.Cog):
def __init__(self,bot):
Expand All @@ -15,12 +17,12 @@ def __init__(self,bot):
async def on_ready(self):
print(f"leaderboard - Loaded")

@nextcord.slash_command(name="leaderboard", description="Frong leaderboard")
@nextcord.slash_command(name="leaderboard", description="Frong leaderboard", guild_ids=[414625175217242113])
async def leaderboard(self, interaction: nextcord.Interaction):
csv_dict = {}
data = ""
total = 0
with open(file_path + "data.csv", 'r') as file:
with open(file_path, 'r') as file:
reader = csv.DictReader(file)

# turn csv into dictionary
Expand All @@ -44,7 +46,7 @@ async def leaderboard(self, interaction: nextcord.Interaction):
embed = nextcord.Embed(title=":crown: **LEADERBOARD**", color=0xd6b509)
embed.add_field(name=":speech_balloon: __FRONGS BY USER__", value=data,inline=False)
embed.add_field(name=":loudspeaker: __TOTAL FRONGS__", value=total,inline=False)
await interaction.response.send_message(embed=embed, ephemeral=True)
await interaction.response.send_message(embed=embed, ephemeral=False)

def setup(bot):
bot.add_cog(Leaderboard(bot))
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

load_dotenv()

file_path = os.path.join(os.getcwd(), "data")
csv_file = "data.csv"
file_path = os.path.join(os.getcwd(), "data")
file_path = os.path.join(file_path, csv_file)
print(file_path)

def update_csv(name, filename):
updated = False
Expand Down

0 comments on commit aeb63d4

Please sign in to comment.