Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Correction de quelques erreurs
Browse files Browse the repository at this point in the history
  • Loading branch information
okayhappex committed Dec 28, 2023
1 parent a8a81f8 commit 36494b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions bot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, value: str = "#ffffff"):

def is_valid(self) -> bool:
for char in range(len(self.value)):
if (char == 0 and self.value[char] != "#") or (char != 0 and self.value[char] not in "0123456789abcdef") or len(self.value) != 7:
if (char == 0 and self.value[char] != "#") or (char != 0 and self.value[char] not in "0123456789abcdefABCDEF") or len(self.value) != 7:
return False

return True
Expand Down Expand Up @@ -95,10 +95,6 @@ def __init__(self, id: int, stats: Stats = Stats(), isAdmin: bool = False, times
self.stats = stats
self.isAdmin = isAdmin
self.timestamp = timestamp

user = users.get(str(id))
if user is None:
users.put(key = str(id), data = self.to_dict())

self.update_from_dict(self.to_dict())

Expand Down Expand Up @@ -352,4 +348,16 @@ def update_from_dict(self, data: dict):
self.blacklist = int_blacklist

def save(self) -> None:
new_users: list[User] = []
for team in self.teams:
for member in team.members:
new_users.append(member)

old_users: list = users.get(str(self.id))["data"]
for user in new_users:
for _user in old_users:
if _user["id"] == user.id:
old_users[old_users.index(_user)] == user.to_dict()

users.update(key = str(self.id), updates = { "data" : old_users })
games.update(key = str(self.id), updates = self.to_dict())
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ async def create(ctx: discord.ApplicationContext, name: str, color: str) -> None
teamColors = [ team.color for team in teams ]

user = utils.User(ctx.author.id, utils.Stats(), True, 0)
user_stats = users.get(str(ctx.author.id))
user_stats = [ _user for _user in users.get(str(ctx.channel.id))["data"] if _user["id"] == user.id ][0]
if user_stats is None:
user_stats = user.to_dict()

del user_stats["key"]
del user_stats["timestamp"]
user.update_from_dict(user_stats)
user.change_status(True)

Expand Down

0 comments on commit 36494b4

Please sign in to comment.