diff options
author | 2021-05-16 18:57:27 +0200 | |
---|---|---|
committer | 2021-05-16 18:57:27 +0200 | |
commit | 3d3a0354053484fc8bf490a0438746f3bc14fc8e (patch) | |
tree | 06655fe9d69758bd1eaad8133cd6c50aa1ecc5e7 /bot | |
parent | Spring cleanup (#718) (diff) | |
parent | Type hint optional parameter (diff) |
Merge pull request #623 from python-discord/pipenv-to-poetry
Pipenv to poetry
Diffstat (limited to 'bot')
-rw-r--r-- | bot/__init__.py | 7 | ||||
-rw-r--r-- | bot/utils/pagination.py | 19 |
2 files changed, 22 insertions, 4 deletions
diff --git a/bot/__init__.py b/bot/__init__.py index e5ed9d92..85ae4758 100644 --- a/bot/__init__.py +++ b/bot/__init__.py @@ -1,3 +1,10 @@ +try: + from dotenv import load_dotenv + print("Found .env file, loading environment variables from it.") + load_dotenv(override=True) +except ModuleNotFoundError: + pass + import asyncio import logging import logging.handlers diff --git a/bot/utils/pagination.py b/bot/utils/pagination.py index 742281d7..d9c0862a 100644 --- a/bot/utils/pagination.py +++ b/bot/utils/pagination.py @@ -27,7 +27,14 @@ class EmptyPaginatorEmbed(Exception): class LinePaginator(Paginator): """A class that aids in paginating code blocks for Discord messages.""" - def __init__(self, prefix: str = "```", suffix: str = "```", max_size: int = 2000, max_lines: int = None): + def __init__( + self, + prefix: str = '```', + suffix: str = '```', + max_size: int = 2000, + max_lines: Optional[int] = None, + linesep: str = "\n" + ): """ Overrides the Paginator.__init__ from inside discord.ext.commands. @@ -36,9 +43,13 @@ class LinePaginator(Paginator): `max_size` and `max_lines` denote the maximum amount of codepoints and lines allowed per page. """ - self.prefix = prefix - self.suffix = suffix - self.max_size = max_size - len(suffix) + super().__init__( + prefix, + suffix, + max_size - len(suffix), + linesep + ) + self.max_lines = max_lines self._current_page = [prefix] self._linecount = 0 |