Implemented /stage add (#2)
This commit is contained in:
@@ -7,7 +7,7 @@ from libbot.cache.classes import CacheMemcached, CacheRedis
|
||||
from libbot.cache.manager import create_cache_client
|
||||
from libbot.pycord.classes import PycordBot as LibPycordBot
|
||||
|
||||
from classes import PycordEvent, PycordGuild, PycordUser
|
||||
from classes import PycordEvent, PycordGuild, PycordUser, PycordEventStage
|
||||
from modules.logging_utils import get_logger
|
||||
|
||||
logger: Logger = get_logger(__name__)
|
||||
@@ -83,6 +83,27 @@ class PycordBot(LibPycordBot):
|
||||
async def create_event(self, **kwargs) -> PycordEvent:
|
||||
return await PycordEvent.create(**kwargs, cache=self.cache)
|
||||
|
||||
# TODO Document this method
|
||||
async def create_event_stage(self, event: PycordEvent, **kwargs) -> PycordEventStage:
|
||||
# TODO Validation is handled by the caller for now, but
|
||||
# ideally this should not be the case at all.
|
||||
#
|
||||
# if "event_id" not in kwargs:
|
||||
# # TODO Create a nicer exception
|
||||
# raise RuntimeError("Event ID must be provided while creating an event stage")
|
||||
#
|
||||
# event: PycordEvent = await self.find_event(event_id=kwargs["event_id"])
|
||||
|
||||
if "sequence" not in kwargs:
|
||||
# TODO Create a nicer exception
|
||||
raise RuntimeError("Stage must have a defined sequence")
|
||||
|
||||
event_stage: PycordEventStage = await PycordEventStage.create(**kwargs, cache=self.cache)
|
||||
|
||||
await event.insert_stage(event_stage._id, kwargs["sequence"], cache=self.cache)
|
||||
|
||||
return event_stage
|
||||
|
||||
async def start(self, *args: Any, **kwargs: Any) -> None:
|
||||
await super().start(*args, **kwargs)
|
||||
|
||||
|
Reference in New Issue
Block a user