From 7b40a647cff01c31f8ec7cac8e60ad0af7984481 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 28 Nov 2021 12:31:48 +1100 Subject: [PATCH 1/5] Added apikey to Rawg.io api requests --- gamesearch/gamesearch.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/gamesearch/gamesearch.py b/gamesearch/gamesearch.py index 44754ae..3d66a56 100644 --- a/gamesearch/gamesearch.py +++ b/gamesearch/gamesearch.py @@ -11,15 +11,28 @@ class Gamesearch(BaseCog): """Search Rawg.io for games""" - + + def __init__(self): + self.config = Config.get_conf(self, identifier=7535876897) + default_global = {"apikey": ""} + self.config.register_global(**default_global) + @commands.command() @cached(ttl=86400, cache=SimpleMemoryCache) @commands.bot_has_permissions(embed_links=True, add_reactions=True) async def game(self, ctx, *, game): """Search Rawg.io for games""" + + # Get API key + apikey = await self.config.apikey() + if apikey == "": + await ctx.send("No rawgkey set, please set one using [p]rawgkey") + return + url = "https://api.rawg.io/api/games?"+urlencode({ "search": game, + "key": apikey, }) # Queries api for a game @@ -35,7 +48,7 @@ async def game(self, ctx, *, game): for game in results: # Build Embed async with aiohttp.ClientSession() as session: - async with session.get(f"https://api.rawg.io/api/games/{game['id']}") as response: + async with session.get(f"https://api.rawg.io/api/games/{game['id']}?key={apikey}") as response: game_details = await response.json() embed = discord.Embed() embed.title=f"{game['name']}" @@ -51,3 +64,15 @@ async def game(self, ctx, *, game): embeds.append(embed) await menu(ctx, pages=embeds, controls=DEFAULT_CONTROLS, message=None, page=0, timeout=20) + + @commands.command() + @checks.is_owner() + async def rawgkey(self, ctx, *, key): + """Set a key to use the rawg api""" + + # Load config + config_boards = await self.config.apikey() + + # Set new config + await self.config.apikey.set(key) + await ctx.send("The apikey has been added.") From c2c9732df8b1b132c0c9b277f9c729d0e3958af1 Mon Sep 17 00:00:00 2001 From: Lemon Rose Date: Thu, 27 Apr 2023 17:27:21 +0530 Subject: [PATCH 2/5] [ConverstaionGames] dpy2 async await load --- conversationgames/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conversationgames/__init__.py b/conversationgames/__init__.py index 325bdef..081d7b4 100644 --- a/conversationgames/__init__.py +++ b/conversationgames/__init__.py @@ -1,6 +1,6 @@ from .conversationgames import ConversationGames -def setup(bot): +async def setup(bot): n = ConversationGames() - bot.add_cog(n) + await bot.add_cog(n) From adff3d36f93a9d93eb36bf1ca25cb3dafd0e4192 Mon Sep 17 00:00:00 2001 From: Lemon Rose Date: Thu, 27 Apr 2023 17:27:48 +0530 Subject: [PATCH 3/5] [AniSearch] dpy2 async await loading --- anisearch/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/anisearch/__init__.py b/anisearch/__init__.py index d8f9665..c30e93b 100644 --- a/anisearch/__init__.py +++ b/anisearch/__init__.py @@ -1,6 +1,6 @@ from .anisearch import AniSearch -def setup(bot): +async def setup(bot): n = AniSearch() - bot.add_cog(n) + await bot.add_cog(n) From e22c7c98ca6d5c34aafc7de7b28d34c48baad31d Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 4 May 2023 18:33:26 +0930 Subject: [PATCH 4/5] [gamesearch] dpy2 async await loading Fix for Redbot 3.5 https://github.com/Cog-Creators/Red-DiscordBot/pull/5600 --- gamesearch/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamesearch/__init__.py b/gamesearch/__init__.py index 8ed57da..a7ad3a6 100644 --- a/gamesearch/__init__.py +++ b/gamesearch/__init__.py @@ -1,6 +1,6 @@ from .gamesearch import Gamesearch -def setup(bot): +async def setup(bot): n = Gamesearch() - bot.add_cog(n) + await bot.add_cog(n) From fa6e8731672c5d5a7b0b38fd8165114aa2662245 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 4 May 2023 18:41:12 +0930 Subject: [PATCH 5/5] [imdb] dpy2 async await loading --- imdb/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imdb/__init__.py b/imdb/__init__.py index b9a2c3e..39a6e62 100644 --- a/imdb/__init__.py +++ b/imdb/__init__.py @@ -1,6 +1,6 @@ from .imdb import Imdb -def setup(bot): +async def setup(bot): n = Imdb() - bot.add_cog(n) + await bot.add_cog(n)