Files
QuizBot/classes/errors/pycord_event.py

27 lines
870 B
Python

from typing import Optional
from bson import ObjectId
class EventNotFoundError(Exception):
"""PycordEvent could not find event with such an ID in the database"""
def __init__(
self,
event_id: Optional[str | ObjectId] = None,
event_name: Optional[str] = None,
guild_id: Optional[int] = None,
) -> None:
self.event_id: str | ObjectId | None = event_id
self.event_name: str | None = event_name
self.guild_id: int | None = guild_id
if self.event_id is None and self.event_name is None:
raise AttributeError("Either event id or name must be provided")
super().__init__(
f"Event with id {self.event_id} was not found"
if event_id is not None
else f"Event with name {self.event_name} was not found for the guild {self.guild_id}"
)