aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Kronifer <[email protected]>2021-03-04 10:35:38 -0600
committerGravatar GitHub <[email protected]>2021-03-04 10:35:38 -0600
commite222ece92b4d14f4a9bb148f28acf9770da44d1b (patch)
tree0407453321a26d3c8a45b7269eb34099a2c8bf6c
parentfixed pipfile.lock because of a previous mistake (diff)
Changes requested by @ChrisLovering
-rw-r--r--bot/exts/easter/earth_photos.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py
index 001f8f41..3ab8e7d9 100644
--- a/bot/exts/easter/earth_photos.py
+++ b/bot/exts/easter/earth_photos.py
@@ -1,10 +1,12 @@
+import logging
+
import discord
from discord.ext import commands
from bot.constants import Colours
from bot.constants import Tokens
-UnClient_id = Tokens.unsplash_key
+log = logging.getLogger(__name__)
class EarthPhotos(commands.Cog):
@@ -19,7 +21,7 @@ class EarthPhotos(commands.Cog):
async with ctx.typing():
async with self.bot.http_session.get(
'https://api.unsplash.com/photos/random',
- params={"query": "earth", "client_id": UnClient_id}) as r:
+ params={"query": "earth", "client_id": Tokens.unsplash_access_key}) as r:
jsondata = await r.json()
linksdata = jsondata.get("urls")
embedlink = linksdata.get("regular")
@@ -30,9 +32,10 @@ class EarthPhotos(commands.Cog):
profile = userlinks.get("html")
async with self.bot.http_session.get(
downloadlinksdata.get("download_location"),
- params={"client_id": UnClient_id}
- ) as _:
+ params={"client_id": Tokens.unsplash_access_key}
+ ) as er:
pass
+
embed = discord.Embed(
title="Earth Photo",
description="A photo of earth from Unsplash.",
@@ -45,4 +48,7 @@ class EarthPhotos(commands.Cog):
def setup(bot: commands.Bot) -> None:
"""Load the Earth Photos cog."""
+ if not Tokens.unsplash_access_key:
+ log.warning("No Unsplash access key found. Cog not loading.")
+ return
bot.add_cog(EarthPhotos(bot))