diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | botcore/_bot.py | 11 | ||||
| -rw-r--r-- | pyproject.toml | 2 | 
3 files changed, 10 insertions, 6 deletions
| diff --git a/CHANGELOG.md b/CHANGELOG.md index f78ef928..47805c6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@  # Changelog +## 5.0.4 18th April 2022 +- Feature: Allow passing an `api_client` to `BotBase`.`__init__` to specify the `botcore.site_api.APIClient` instance to use. +  ## 5.0.3 18th April 2022  - Fix: Reconnect to redis session on setup if it is closed. diff --git a/botcore/_bot.py b/botcore/_bot.py index 69ccdc1c..90de58a5 100644 --- a/botcore/_bot.py +++ b/botcore/_bot.py @@ -40,6 +40,7 @@ class BotBase(commands.Bot):          allowed_roles: list,          http_session: aiohttp.ClientSession,          redis_session: Optional[RedisSession] = None, +        api_client: Optional[APIClient] = None,          **kwargs,      ):          """ @@ -49,9 +50,10 @@ class BotBase(commands.Bot):              guild_id: The ID of the guild use for :func:`wait_until_guild_available`.              allowed_roles: A list of role IDs that the bot is allowed to mention.              http_session (aiohttp.ClientSession): The session to use for the bot. -            redis_session: The -                ``[async_rediscache.RedisSession](https://github.com/SebastiaanZ/async-rediscache#creating-a-redissession)`` -                to use for the bot. +            redis_session: The `async_rediscache.RedisSession`_ to use for the bot. +            api_client: The :obj:`botcore.site_api.APIClient` instance to use for the bot. + +        .. _async_rediscache.RedisSession: https://github.com/SebastiaanZ/async-rediscache#creating-a-redissession          """          super().__init__(              *args, @@ -61,14 +63,13 @@ class BotBase(commands.Bot):          self.guild_id = guild_id          self.http_session = http_session +        self.api_client = api_client          if redis_session and RedisSession == discord.utils._MissingSentinel:              warnings.warn("redis_session kwarg passed, but async-rediscache not installed!")          elif redis_session:              self.redis_session = redis_session -        self.api_client: Optional[APIClient] = None -          self._resolver: Optional[aiohttp.AsyncResolver] = None          self._connector: Optional[aiohttp.TCPConnector] = None diff --git a/pyproject.toml b/pyproject.toml index 1ad6edd9..0815e65a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@  [tool.poetry]  name = "bot-core" -version = "5.0.3" +version = "5.0.4"  description = "Bot-Core provides the core functionality and utilities for the bots of the Python Discord community."  authors = ["Python Discord <[email protected]>"]  license = "MIT" | 
