Skip to content

Commit 0d11f77

Browse files
authored
fix: don't create Asset with empty hash in User.banner (#1776)
The `banner` field in the Discord API `User` object is both nullable and can be missing. When a User is fetched with `force=True` to obtain the `banner` value, due to how the data is processed, an Asset with hash=None may be erroneously created, whose url points to `None.png`. This fix makes User correctly process the null `banner` such that User.banner would become `None` in that case, rather than `Asset(hash=None)`. The similar Member object processed `banner` correctly and is not affected by this bug.
1 parent ff1f1d5 commit 0d11f77

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

interactions/models/discord/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _process_dict(cls, data: Dict[str, Any], client: "Client") -> Dict[str, Any]
171171
if any(field in data for field in ("banner", "accent_color", "avatar_decoration")):
172172
data["_fetched"] = True
173173

174-
if "banner" in data:
174+
if data.get("banner", None):
175175
data["banner"] = Asset.from_path_hash(client, f"banners/{data['id']}/{{}}", data["banner"])
176176

177177
if data.get("premium_type", None) is None:

0 commit comments

Comments
 (0)