Files
QuizBot/classes/errors/pycord_event.py

21 lines
689 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) -> None:
self.event_id = event_id
self.event_name = event_name
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"
)