Improved handling of larger event stages
This commit is contained in:
@@ -329,17 +329,25 @@ class CogEvent(Cog):
|
||||
|
||||
# TODO Make a nice message
|
||||
stages_string: str = "\n\n".join(
|
||||
f"**Stage {stage.sequence+1}**\nQuestion: {stage.question}\nAnswer: ||{stage.answer}||"
|
||||
for stage in stages
|
||||
f"**Stage {stage.sequence+1}**\nAnswer: ||{stage.answer}||" for stage in stages
|
||||
)
|
||||
|
||||
# TODO Show users registered for the event
|
||||
|
||||
# TODO Introduce i18n
|
||||
await ctx.respond(
|
||||
event_info_string: str = (
|
||||
f"**Event details**\n\nName: {pycord_event.name}\nStarts: <t:{get_unix_timestamp(starts_date)}>\nEnds: <t:{get_unix_timestamp(ends_date)}>\n\nStages:\n{stages_string}"
|
||||
)
|
||||
|
||||
chunk_size: int = 2000
|
||||
|
||||
event_info_chunks: List[str] = [
|
||||
event_info_string[i : i + chunk_size] for i in range(0, len(event_info_string), chunk_size)
|
||||
]
|
||||
|
||||
for chunk in event_info_chunks:
|
||||
await ctx.respond(chunk)
|
||||
|
||||
|
||||
def setup(bot: PycordBot) -> None:
|
||||
bot.add_cog(CogEvent(bot))
|
||||
|
@@ -96,10 +96,11 @@ class CogGuess(Cog):
|
||||
|
||||
files: List[File] | None = next_stage.get_media_files()
|
||||
|
||||
await ctx.respond(
|
||||
f"Provided answer is correct! Next stage...\n\n{next_stage.question}",
|
||||
files=files,
|
||||
)
|
||||
next_question_chunks: List[str] = next_stage.get_question_chunked(2000)
|
||||
next_question_chunks_length: int = len(next_question_chunks)
|
||||
|
||||
for index, chunk in enumerate(next_question_chunks):
|
||||
await ctx.respond(chunk, files=None if index != next_question_chunks_length - 1 else files)
|
||||
|
||||
await user.set_event_stage(next_stage._id, cache=self.bot.cache)
|
||||
|
||||
|
@@ -112,7 +112,13 @@ class CogRegister(Cog):
|
||||
|
||||
first_stage_files: List[File] | None = first_stage.get_media_files()
|
||||
|
||||
await user_channel.send(f"First stage...\n\n{first_stage.question}", files=first_stage_files)
|
||||
question_chunks: List[str] = first_stage.get_question_chunked(2000)
|
||||
question_chunks_length: int = len(question_chunks)
|
||||
|
||||
for index, chunk in enumerate(question_chunks):
|
||||
await user_channel.send(
|
||||
chunk, files=None if index != question_chunks_length - 1 else first_stage_files
|
||||
)
|
||||
|
||||
|
||||
def setup(bot: PycordBot) -> None:
|
||||
|
@@ -57,6 +57,7 @@ class CogStage(Cog):
|
||||
description_localizations=in_every_locale(
|
||||
"description", "commands", "stage_add", "options", "answer"
|
||||
),
|
||||
max_length=500,
|
||||
required=True,
|
||||
)
|
||||
@option(
|
||||
@@ -155,6 +156,7 @@ class CogStage(Cog):
|
||||
description_localizations=in_every_locale(
|
||||
"description", "commands", "stage_edit", "options", "answer"
|
||||
),
|
||||
max_length=500,
|
||||
required=False,
|
||||
)
|
||||
@option(
|
||||
|
Reference in New Issue
Block a user