aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2021-03-10 22:03:59 +0100
committerGravatar kwzrd <[email protected]>2021-03-13 12:39:42 +0100
commit0810b76e448f8b13b760eb29c080a7d576959821 (patch)
treebc3b2bded40db255f5d80dc040fae23881ae45ab
parentBranding: correctly annotate optional attribute (diff)
Branding: do not require 'RemoteObject' instance to fetch file
-rw-r--r--bot/exts/backend/branding/_repository.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bot/exts/backend/branding/_repository.py b/bot/exts/backend/branding/_repository.py
index 133231968..1a6b13c8b 100644
--- a/bot/exts/backend/branding/_repository.py
+++ b/bot/exts/backend/branding/_repository.py
@@ -94,15 +94,15 @@ class BrandingRepository:
return {file["name"]: RemoteObject(file) for file in json_directory if file["type"] in types}
- async def fetch_file(self, file: RemoteObject) -> t.Optional[bytes]:
+ async def fetch_file(self, download_url: str) -> t.Optional[bytes]:
"""
- Fetch `file` using its download URL.
+ Fetch file from `download_url`.
Returns the file as bytes unless the request fails, in which case None is given.
"""
- log.debug(f"Fetching file from branding repository: {file.download_url}")
+ log.debug(f"Fetching file from branding repository: {download_url}")
- async with self.bot.http_session.get(file.download_url, params=PARAMS, headers=HEADERS) as response:
+ async with self.bot.http_session.get(download_url, params=PARAMS, headers=HEADERS) as response:
if response.status == 200:
return await response.read()
else:
@@ -155,7 +155,7 @@ class BrandingRepository:
if len(server_icons) == 0:
raise BrandingMisconfiguration("Found no server icons!")
- meta_bytes = await self.fetch_file(contents["meta.md"])
+ meta_bytes = await self.fetch_file(contents["meta.md"].download_url)
if meta_bytes is None:
raise BrandingMisconfiguration("Failed to fetch 'meta.md' file!")