Pincer-org /
Pincer-Bot
| 1 | import os |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 2 | from glob import glob |
||
| 3 | from time import perf_counter |
||
| 4 | |||
| 5 | import dotenv |
||
| 6 | from pincer import Client |
||
| 7 | from pincer_bot.classes.pypi import PyPI |
||
| 8 | |||
| 9 | |||
| 10 | View Code Duplication | class Bot(Client): |
|
|
0 ignored issues
–
show
|
|||
| 11 | |||
| 12 | def __init__(self, *args, **kwargs): |
||
| 13 | self.load_cogs() |
||
| 14 | |||
| 15 | dotenv.load_dotenv('.env') |
||
| 16 | super().__init__(token=os.environ.get('TOKEN'), *args, **kwargs) |
||
| 17 | |||
| 18 | self.pypi = PyPI() |
||
| 19 | self.start_time = perf_counter() |
||
| 20 | |||
| 21 | def load_cogs(self): |
||
| 22 | """Load all cogs from the `cogs` directory.""" |
||
| 23 | for cog in glob("pincer_bot/cogs/*.py"): |
||
| 24 | self.load_cog(cog.replace("/", ".").replace("\\", ".")[:-3]) |
||
| 25 | print("Loaded cogs from", cog) |
||
| 26 | |||
| 27 | @Client.event |
||
| 28 | async def on_ready(self): |
||
|
0 ignored issues
–
show
|
|||
| 29 | print( |
||
| 30 | f"Logged in as {self.bot} " |
||
| 31 | f"after {perf_counter() - self.start_time:.3f} seconds." |
||
| 32 | ) |
||
| 33 |