Fixed event not being set as ended correctly
This commit is contained in:
@@ -63,7 +63,11 @@ class PycordBot(LibPycordBot):
|
|||||||
async def _process_events_start(self) -> None:
|
async def _process_events_start(self) -> None:
|
||||||
# Get events to start
|
# Get events to start
|
||||||
events: List[PycordEvent] = await self._get_events(
|
events: List[PycordEvent] = await self._get_events(
|
||||||
{"starts": datetime.now(tz=ZoneInfo("UTC")).replace(second=0, microsecond=0)}
|
{
|
||||||
|
"starts": datetime.now(tz=ZoneInfo("UTC")).replace(second=0, microsecond=0),
|
||||||
|
"is_cancelled": False,
|
||||||
|
"ended": None,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Process each event
|
# Process each event
|
||||||
@@ -171,6 +175,8 @@ class PycordBot(LibPycordBot):
|
|||||||
f"Event **{event.name}** has ended! Users can no longer submit their answers.",
|
f"Event **{event.name}** has ended! Users can no longer submit their answers.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await event.end(cache=self.cache)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _get_events(query: Dict[str, Any]) -> List[PycordEvent]:
|
async def _get_events(query: Dict[str, Any]) -> List[PycordEvent]:
|
||||||
events: List[PycordEvent] = []
|
events: List[PycordEvent] = []
|
||||||
|
@@ -268,6 +268,10 @@ class PycordEvent:
|
|||||||
async def cancel(self, cache: Optional[Cache] = None):
|
async def cancel(self, cache: Optional[Cache] = None):
|
||||||
await self._set(cache, is_cancelled=True)
|
await self._set(cache, is_cancelled=True)
|
||||||
|
|
||||||
|
# # TODO Add documentation
|
||||||
|
async def end(self, cache: Optional[Cache] = None) -> None:
|
||||||
|
await self._set(cache, ended=datetime.now(tz=ZoneInfo("UTC")))
|
||||||
|
|
||||||
async def _update_event_stage_order(
|
async def _update_event_stage_order(
|
||||||
self,
|
self,
|
||||||
bot: Any,
|
bot: Any,
|
||||||
@@ -325,7 +329,7 @@ class PycordEvent:
|
|||||||
# # TODO Add documentation
|
# # TODO Add documentation
|
||||||
# def get_localized_start_date(self, tz: str | timezone | ZoneInfo) -> datetime:
|
# def get_localized_start_date(self, tz: str | timezone | ZoneInfo) -> datetime:
|
||||||
# return self.starts.replace(tzinfo=tz)
|
# return self.starts.replace(tzinfo=tz)
|
||||||
#
|
|
||||||
# # TODO Add documentation
|
# TODO Add documentation
|
||||||
# def get_localized_end_date(self, tz: str | timezone | ZoneInfo) -> datetime:
|
# def get_localized_end_date(self, tz: str | timezone | ZoneInfo) -> datetime:
|
||||||
# return self.ends.replace(tzinfo=tz)
|
# return self.ends.replace(tzinfo=tz)
|
||||||
|
Reference in New Issue
Block a user