aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/easter/earth_photos.py
diff options
context:
space:
mode:
authorGravatar Shivansh-007 <[email protected]>2021-05-20 18:30:07 +0530
committerGravatar GitHub <[email protected]>2021-05-20 18:30:07 +0530
commitd032dd1a0e0fb0f866b1b492f917990d66dae55a (patch)
tree0adfc37d1350c7eb0b33ea44d4170a44a017e119 /bot/exts/easter/earth_photos.py
parentMerge remote-tracking branch 'origin/feature/command-suggestions' into featur... (diff)
parentMerge pull request #733 from Icebluewolf/http_status_command_randomness (diff)
Merge branch 'main' into feature/command-suggestions
Diffstat (limited to 'bot/exts/easter/earth_photos.py')
-rw-r--r--bot/exts/easter/earth_photos.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bot/exts/easter/earth_photos.py b/bot/exts/easter/earth_photos.py
index bf658391..f65790af 100644
--- a/bot/exts/easter/earth_photos.py
+++ b/bot/exts/easter/earth_photos.py
@@ -3,24 +3,27 @@ import logging
import discord
from discord.ext import commands
+from bot.bot import Bot
from bot.constants import Colours
from bot.constants import Tokens
log = logging.getLogger(__name__)
+API_URL = "https://api.unsplash.com/photos/random"
+
class EarthPhotos(commands.Cog):
"""This cog contains the command for earth photos."""
- def __init__(self, bot: commands.Bot):
+ def __init__(self, bot: Bot):
self.bot = bot
- @commands.command(aliases=["earth"])
+ @commands.command(aliases=("earth",))
async def earth_photos(self, ctx: commands.Context) -> None:
"""Returns a random photo of earth, sourced from Unsplash."""
async with ctx.typing():
async with self.bot.http_session.get(
- 'https://api.unsplash.com/photos/random',
+ API_URL,
params={"query": "planet_earth", "client_id": Tokens.unsplash_access_key}
) as r:
jsondata = await r.json()
@@ -55,7 +58,7 @@ class EarthPhotos(commands.Cog):
await ctx.send(embed=embed)
-def setup(bot: commands.Bot) -> None:
+def setup(bot: Bot) -> None:
"""Load the Earth Photos cog."""
if not Tokens.unsplash_access_key:
log.warning("No Unsplash access key found. Cog not loading.")