Skip to content

Commit

Permalink
Fix crash when game has no icon attribute. These games will not have …
Browse files Browse the repository at this point in the history
…icon in HA, but other information will still be available.
  • Loading branch information
LordBoos committed Nov 29, 2023
1 parent 52fb3b2 commit d56e2be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions custom_components/discord_game/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"domain": "discord_game",
"name": "Discord Game",
"version": "5.0.3",
"version": "5.0.4",
"documentation": "",
"dependencies": [],
"codeowners": [],
"requirements": ["nextcord==2.0.0a8", "addict", "aiohttp"]
"requirements": ["nextcord==2.5.0", "addict", "aiohttp"]
}
8 changes: 5 additions & 3 deletions custom_components/discord_game/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,14 @@ async def load_game_image(activity: Union[Activity, Game, Streaming]):
discord_app = list(filter(lambda app: app['id'] == str(app_id), app_list))
if discord_app:
_LOGGER.debug("FOUND discord app by application_id = %s", discord_app)
watcher._game_image_small = f"https://cdn.discordapp.com/app-icons/{discord_app[0]['id']}/{discord_app[0]['icon']}.png"
if hasattr(discord_app[0], 'icon'):
watcher._game_image_small = f"https://cdn.discordapp.com/app-icons/{discord_app[0]['id']}/{discord_app[0]['icon']}.png"
discord_app_by_name = list(filter(lambda app: app['name'] == str(activity.name), app_list))
if discord_app_by_name:
_LOGGER.debug("FOUND discord app by name = %s", discord_app_by_name)
watcher._game_image_small = \
f"https://cdn.discordapp.com/app-icons/{discord_app_by_name[0]['id']}/{discord_app_by_name[0]['icon']}.png"
if hasattr(discord_app_by_name[0], 'icon'):
watcher._game_image_small = \
f"https://cdn.discordapp.com/app-icons/{discord_app_by_name[0]['id']}/{discord_app_by_name[0]['icon']}.png"
steam_app_by_name = list(filter(lambda steam_app: steam_app['name'] == str(activity.name), steam_app_list))
if steam_app_by_name:
steam_app_id = steam_app_by_name[0]["appid"]
Expand Down

0 comments on commit d56e2be

Please sign in to comment.