GloryBot/classes/pycordbot.py
2024-05-01 21:15:35 +02:00

44 lines
1.2 KiB
Python

from typing import Any, Union
from aiohttp import ClientSession
from bson import ObjectId
from libbot.pycord.classes import PycordBot as LibPycordBot
from classes.pycordmember import PycordMember
class PycordBot(LibPycordBot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.client_session = ClientSession()
if self.scheduler is None:
return
async def find_user(
self, id: Union[int, ObjectId], guild: ObjectId
) -> PycordMember:
"""Find member by their ID and guild.
### Args:
* id (`Union[int, ObjectId]`): Member's Discord ID
* guild (`ObjectId`): Discord guild's database ID
### Raises:
* `MemberNotFoundError`: Raised when member entry after insertion could not be found.
### Returns:
* `PycordMember`: Member in database representation.
"""
return await PycordMember.find(id, guild)
async def close(self, *args: Any, **kwargs: Any) -> None:
await self.client_session.close()
if self.scheduler is not None:
self.scheduler.shutdown()
await super().close(*args, **kwargs)