Closes #11
This commit is contained in:
@@ -18,6 +18,7 @@ from classes.errors import (
|
||||
EventStageMissingSequenceError,
|
||||
EventStageNotFoundError,
|
||||
GuildNotFoundError,
|
||||
DiscordGuildMemberNotFoundError,
|
||||
)
|
||||
from modules.database import col_events, col_users
|
||||
from modules.utils import get_logger
|
||||
@@ -118,9 +119,25 @@ class PycordBot(LibPycordBot):
|
||||
await user._set(self.cache, current_event_id=event._id, current_stage_id=first_stage._id)
|
||||
|
||||
# Create a channel for each participant
|
||||
user_channel: TextChannel | None = await user.setup_event_channel(
|
||||
self, guild, pycord_guild, event, cache=self.cache
|
||||
)
|
||||
try:
|
||||
user_channel: TextChannel | None = await user.setup_event_channel(
|
||||
self, guild, pycord_guild, event, cache=self.cache
|
||||
)
|
||||
except DiscordGuildMemberNotFoundError:
|
||||
logger.error(
|
||||
"Could not create and configure event channel for user %s in %s (event %s): user not found in the guild",
|
||||
user.id,
|
||||
guild.id,
|
||||
event._id,
|
||||
)
|
||||
|
||||
await self.notify_admins(
|
||||
guild,
|
||||
pycord_guild,
|
||||
f"Event channel could not be created for user with ID `{user.id}` (<@{user.id}>) and event **{event.name}**: user was not found on the server.",
|
||||
)
|
||||
|
||||
continue
|
||||
|
||||
if user_channel is None:
|
||||
logger.error(
|
||||
@@ -374,3 +391,25 @@ class PycordBot(LibPycordBot):
|
||||
processed_attachments.append({"id": attachment.id, "filename": attachment.filename})
|
||||
|
||||
return processed_attachments
|
||||
|
||||
# TODO Add documentation
|
||||
async def send_stage_question(
|
||||
self,
|
||||
channel: TextChannel,
|
||||
event: PycordEvent,
|
||||
stage: Optional[PycordEventStage] = None,
|
||||
use_first_stage: bool = False,
|
||||
) -> None:
|
||||
stage: PycordEventStage = (
|
||||
stage
|
||||
if not use_first_stage or stage is not None
|
||||
else await self.find_event_stage(event.stage_ids[0])
|
||||
)
|
||||
|
||||
stage_files: List[File] | None = stage.get_media_files()
|
||||
|
||||
question_chunks: List[str] = stage.get_question_chunked(2000)
|
||||
question_chunks_length: int = len(question_chunks)
|
||||
|
||||
for index, chunk in enumerate(question_chunks):
|
||||
await channel.send(chunk, files=None if index != question_chunks_length - 1 else stage_files)
|
||||
|
Reference in New Issue
Block a user