|
29 | 29 |
|
30 | 30 |
|
31 | 31 | async def start_bot(bot: custom.Bot, token: str, rest_config: RestConfig, public_key: str | None = None) -> None: |
32 | | - try: |
33 | | - if isinstance(bot, custom.CustomRestBot): |
34 | | - if not public_key: |
35 | | - raise TypeError("CustomRestBot requires a public key to start.") # noqa: TRY301 |
36 | | - await bot.start( |
37 | | - token=token, |
38 | | - public_key=public_key, |
39 | | - health=rest_config.health, |
40 | | - uvicorn_options={ |
41 | | - "host": rest_config.host, |
42 | | - "port": rest_config.port, |
43 | | - }, |
44 | | - ) |
45 | | - else: |
46 | | - await bot.start(token) |
47 | | - except LoginFailure as e: |
48 | | - logger.critical("Failed to log in, is the bot token valid?") |
49 | | - logger.debug("", exc_info=e) |
50 | | - except Exception as e: # noqa: BLE001 |
51 | | - logger.critical("An unexpected error occurred while starting the bot.") |
52 | | - logger.debug("", exc_info=e) |
| 32 | + try: |
| 33 | + if isinstance(bot, custom.CustomRestBot): |
| 34 | + if not public_key: |
| 35 | + raise TypeError("CustomRestBot requires a public key to start.") # noqa: TRY301 |
| 36 | + await bot.start( |
| 37 | + token=token, |
| 38 | + public_key=public_key, |
| 39 | + health=rest_config.health, |
| 40 | + uvicorn_options={ |
| 41 | + "host": rest_config.host, |
| 42 | + "port": rest_config.port, |
| 43 | + }, |
| 44 | + ) |
| 45 | + else: |
| 46 | + await bot.start(token) |
| 47 | + except LoginFailure as e: |
| 48 | + logger.critical("Failed to log in, is the bot token valid?") |
| 49 | + logger.debug("", exc_info=e) |
| 50 | + except Exception as e: # noqa: BLE001 |
| 51 | + logger.critical("An unexpected error occurred while starting the bot.") |
| 52 | + logger.debug("", exc_info=e) |
53 | 53 |
|
54 | 54 |
|
55 | 55 | # blerp |
56 | 56 |
|
| 57 | + |
57 | 58 | async def start_backend(app: Quart, bot: discord.Bot, token: str) -> None: |
58 | 59 | from hypercorn.asyncio import serve # pyright: ignore [reportUnknownVariableType] |
59 | 60 | from hypercorn.config import Config |
|
0 commit comments