aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-12-11 12:44:12 -0800
committerGravatar MarkKoz <[email protected]>2019-12-11 12:44:12 -0800
commitddfbfe31b2c2d9e5bc5d46ab9ffffa5b35a63e5f (patch)
tree6ed2f30b24c225f4d98521bea0f74c361a14baef
parentReddit: move token renewal inside fetch_posts (diff)
Reddit: move BasicAuth instantiation to __init__
The object is basically just a namedtuple so there's no need to re-create it every time a token is obtained. * Remove log message which shows credentials. * Initialise headers attribute to None in __init__.
-rw-r--r--bot/cogs/reddit.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/bot/cogs/reddit.py b/bot/cogs/reddit.py
index 0802c6102..48f636159 100644
--- a/bot/cogs/reddit.py
+++ b/bot/cogs/reddit.py
@@ -32,8 +32,10 @@ class Reddit(Cog):
self.webhook = None
self.access_token = None
- bot.loop.create_task(self.init_reddit_ready())
+ self.headers = None
+ self.client_auth = BasicAuth(RedditConfig.client_id, RedditConfig.secret)
+ bot.loop.create_task(self.init_reddit_ready())
self.auto_poster_loop.start()
def cog_unload(self) -> None:
@@ -61,9 +63,6 @@ class Reddit(Cog):
"duration": "temporary"
}
- log.info(f"{RedditConfig.client_id}, {RedditConfig.secret}")
- self.client_auth = BasicAuth(RedditConfig.client_id, RedditConfig.secret)
-
for _ in range(self.MAX_RETRIES):
response = await self.bot.http_session.post(
url=f"{self.URL}/api/v1/access_token",