This commit is contained in:
parent
40827e70a1
commit
5e479ddc79
@ -59,3 +59,15 @@ class PycordBot(Bot):
|
|||||||
self.in_every_locale = self.bot_locale.in_every_locale
|
self.in_every_locale = self.bot_locale.in_every_locale
|
||||||
|
|
||||||
self.scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = scheduler
|
self.scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = scheduler
|
||||||
|
|
||||||
|
async def start(self, token: str, reconnect: bool = True, scheduler_start: bool = True) -> None:
|
||||||
|
if self.scheduler is not None and scheduler_start:
|
||||||
|
self.scheduler.start()
|
||||||
|
|
||||||
|
await super().start(token, reconnect=reconnect)
|
||||||
|
|
||||||
|
async def close(self, scheduler_shutdown: bool = True, scheduler_wait: bool = True) -> None:
|
||||||
|
if self.scheduler is not None and scheduler_shutdown:
|
||||||
|
self.scheduler.shutdown(scheduler_wait)
|
||||||
|
|
||||||
|
await super().close()
|
||||||
|
@ -125,7 +125,7 @@ class PyroClient(Client):
|
|||||||
|
|
||||||
self.i18n_bot_info: bool = i18n_bot_info
|
self.i18n_bot_info: bool = i18n_bot_info
|
||||||
|
|
||||||
async def start(self, register_commands: bool = True) -> None:
|
async def start(self, register_commands: bool = True, scheduler_start: bool = True) -> None:
|
||||||
await super().start()
|
await super().start()
|
||||||
|
|
||||||
self.start_time = time()
|
self.start_time = time()
|
||||||
@ -209,9 +209,12 @@ class PyroClient(Client):
|
|||||||
kwargs={"command_sets": await self.collect_commands()},
|
kwargs={"command_sets": await self.collect_commands()},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if scheduler_start:
|
||||||
self.scheduler.start()
|
self.scheduler.start()
|
||||||
|
|
||||||
async def stop(self, exit_completely: bool = True) -> None:
|
async def stop(
|
||||||
|
self, exit_completely: bool = True, scheduler_shutdown: bool = True, scheduler_wait: bool = True
|
||||||
|
) -> None:
|
||||||
try:
|
try:
|
||||||
await self.send_message(
|
await self.send_message(
|
||||||
chat_id=self.owner
|
chat_id=self.owner
|
||||||
@ -223,6 +226,9 @@ class PyroClient(Client):
|
|||||||
except BadRequest:
|
except BadRequest:
|
||||||
logger.warning("Unable to send message to report chat.")
|
logger.warning("Unable to send message to report chat.")
|
||||||
|
|
||||||
|
if self.scheduler is not None and scheduler_shutdown:
|
||||||
|
self.scheduler.shutdown(scheduler_wait)
|
||||||
|
|
||||||
await super().stop()
|
await super().stop()
|
||||||
logger.warning("Bot stopped with PID %s.", getpid())
|
logger.warning("Bot stopped with PID %s.", getpid())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user