diff options
author | 2022-02-05 17:35:57 +0200 | |
---|---|---|
committer | 2022-02-05 19:49:20 +0400 | |
commit | 1e5cdeac8d28e798a144374d331bd137c9b1fd93 (patch) | |
tree | 437e8ee5305b02ff6f164853f27fd9e71fd3e9af /backend | |
parent | Fix Linting Errors (diff) |
Switch To List Comp
Co-authored-by: Bluenix <[email protected]>
Signed-off-by: Hassan Abouelela <[email protected]>
Diffstat (limited to 'backend')
-rw-r--r-- | backend/authentication/user.py | 6 | ||||
-rw-r--r-- | backend/discord.py | 4 |
2 files changed, 2 insertions, 8 deletions
diff --git a/backend/authentication/user.py b/backend/authentication/user.py index 0ec0188..6256cae 100644 --- a/backend/authentication/user.py +++ b/backend/authentication/user.py @@ -47,11 +47,7 @@ class User(BaseUser): return [] server_roles = await discord.get_roles(database) - roles = [] - - for role in server_roles: - if role.id in self.member.roles: - roles.append(role.name) + roles = [role.name for role in server_roles if role.id in self.member.roles] if "admin" in roles: # Protect against collision with the forms admin role diff --git a/backend/discord.py b/backend/discord.py index 6c8eefe..f972f5f 100644 --- a/backend/discord.py +++ b/backend/discord.py @@ -80,9 +80,7 @@ async def get_roles( name="inserted_at", ) - roles = [] - async for role in collection.find(): - roles.append(models.DiscordRole(**json.loads(role["data"]))) + roles = [models.DiscordRole(**json.loads(role["data"])) async for role in collection.find()] if len(roles) == 0: # Fetch roles from the API and insert into the database |