aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/hacktober/spookygif.py
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2018-11-21 13:00:34 +0100
committerGravatar GitHub <[email protected]>2018-11-21 13:00:34 +0100
commit276348d1e6524f895c8427d36b611b27258f369a (patch)
tree7e5e6153b02737624e8b78f932cc15488f3810c4 /bot/cogs/hacktober/spookygif.py
parentMerge branch 'markylon-gif' (diff)
parentResolve Flake8 (diff)
Merge pull request #69 from python-discord/issue/68-with-typing
Typing context manager for Hacktober cogs
Diffstat (limited to 'bot/cogs/hacktober/spookygif.py')
-rw-r--r--bot/cogs/hacktober/spookygif.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/bot/cogs/hacktober/spookygif.py b/bot/cogs/hacktober/spookygif.py
index 1249905d..98a411f6 100644
--- a/bot/cogs/hacktober/spookygif.py
+++ b/bot/cogs/hacktober/spookygif.py
@@ -18,18 +18,19 @@ class SpookyGif:
"""
Fetches a random gif from the GIPHY API and responds with it.
"""
-
- async with aiohttp.ClientSession() as session:
- params = {'api_key': GIPHY_TOKEN, 'tag': 'halloween', 'rating': 'g'}
- # Make a GET request to the Giphy API to get a random halloween gif.
- async with session.get('http://api.giphy.com/v1/gifs/random', params=params) as resp:
- data = await resp.json()
- url = data['data']['image_url']
-
- embed = discord.Embed(colour=0x9b59b6)
- embed.title = "A spooooky gif!"
- embed.set_image(url=url)
- await ctx.send(embed=embed)
+ async with ctx.typing():
+ async with aiohttp.ClientSession() as session:
+ params = {'api_key': GIPHY_TOKEN, 'tag': 'halloween', 'rating': 'g'}
+ # Make a GET request to the Giphy API to get a random halloween gif.
+ async with session.get('http://api.giphy.com/v1/gifs/random', params=params) as resp:
+ data = await resp.json()
+ url = data['data']['image_url']
+
+ embed = discord.Embed(colour=0x9b59b6)
+ embed.title = "A spooooky gif!"
+ embed.set_image(url=url)
+
+ await ctx.send(embed=embed)
def setup(bot):