Added more custom exceptions and prepared everything for documentation
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
from bson import ObjectId
|
||||
|
||||
|
||||
class UserNotFoundError(Exception):
|
||||
"""PycordUser could not find user with such an ID in the database"""
|
||||
|
||||
@@ -6,3 +9,33 @@ class UserNotFoundError(Exception):
|
||||
self.guild_id: int = guild_id
|
||||
|
||||
super().__init__(f"User with id {self.user_id} was not found in guild {self.guild_id}")
|
||||
|
||||
|
||||
class UserAlreadyRegisteredForEventError(Exception):
|
||||
"""PycordUser is already registered for the provided event"""
|
||||
|
||||
def __init__(self, user_id: int, event_id: str | ObjectId) -> None:
|
||||
self.user_id: int = user_id
|
||||
self.event_id: str | ObjectId = event_id
|
||||
|
||||
super().__init__(f"User with id {self.user_id} is already registered for the event {self.event_id}")
|
||||
|
||||
|
||||
class UserNotRegisteredForEventError(Exception):
|
||||
"""PycordUser is not registered for the provided event"""
|
||||
|
||||
def __init__(self, user_id: int, event_id: str | ObjectId) -> None:
|
||||
self.user_id: int = user_id
|
||||
self.event_id: str | ObjectId = event_id
|
||||
|
||||
super().__init__(f"User with id {self.user_id} is not registered for the event {self.event_id}")
|
||||
|
||||
|
||||
class UserAlreadyCompletedEventError(Exception):
|
||||
"""PycordUser already completed the provided event"""
|
||||
|
||||
def __init__(self, user_id: int, event_id: str | ObjectId) -> None:
|
||||
self.user_id: int = user_id
|
||||
self.event_id: str | ObjectId = event_id
|
||||
|
||||
super().__init__(f"User with id {self.user_id} already completed the event {self.event_id}")
|
||||
|
Reference in New Issue
Block a user