GloryBot/classes/errors/member.py

42 lines
1.3 KiB
Python
Raw Normal View History

2024-05-01 22:15:35 +03:00
from typing import Union
2024-06-02 22:51:07 +03:00
2024-05-01 22:15:35 +03:00
from bson import ObjectId
class MemberNotFoundError(Exception):
"""Exception raised when member does not exist in a database.
### Attributes:
2024-06-02 22:51:07 +03:00
* id (`Union[int, ObjectId]`): Member ID.
* guild (`ObjectId`): Member's guild.
2024-05-01 22:15:35 +03:00
"""
def __init__(self, id: Union[int, ObjectId], guild: ObjectId):
2024-06-02 22:51:07 +03:00
self.id: Union[int, ObjectId] = id
self.guild: ObjectId = guild
2024-05-01 22:15:35 +03:00
super().__init__(
f"Could not find member entry for {str(id)} in the guild with id {str(guild)}."
)
def __str__(self):
return f"Could not find member entry for {str(self.id)} in the guild with id {str(self.guild)}."
2024-06-02 22:51:07 +03:00
class MemberAlreadyExistsError(Exception):
"""Exception raised when attempted member creation when it already exists in a database.
### Attributes:
* id (`Union[int, ObjectId]`): Member ID.
* guild (`ObjectId`): Member's guild.
"""
def __init__(self, id: Union[int, ObjectId], guild: ObjectId):
self.id: Union[int, ObjectId] = id
self.guild: ObjectId = guild
super().__init__(
f"Member entry for {str(id)} in the guild with id {str(guild)} already exists."
)
def __str__(self):
return f"Member entry for {str(self.id)} in the guild with id {str(self.guild)} already exists."