-
Notifications
You must be signed in to change notification settings - Fork 22
Add chall solves #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add chall solves #52
Conversation
embed.add_field( | ||
name=name, | ||
value=f"{time_since(solver.solved_at)}", | ||
inline=False, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of introducing a new helper function for this, it would be cleaner and more efficient to use Discord's built-in relative timestamp format (<t:${timestamp}:R>
). It automatically shows the relative time and updates in real time, so there's no need to handle that manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -37,6 +38,7 @@ | |||
get_ctf_info, | |||
sanitize_channel_name, | |||
strip_url_components, | |||
time_since, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time_since, |
""" | ||
Show the list of solvers for the provided/current challenge. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
Show the list of solvers for the provided/current challenge. | |
""" | |
"""Show the list of solvers for a given challenge. | |
Args: | |
interaction: The interaction that triggered this command. | |
name: The challenge name (default: current thread's challenge). | |
""" |
async def followup(content: str, ephemeral=True, **kwargs) -> None: | ||
if not interaction: | ||
return | ||
await interaction.followup.send(content, ephemeral=ephemeral, **kwargs) | ||
|
||
await interaction.response.defer() | ||
|
||
if name is None: | ||
challenge = get_challenge_info(thread=interaction.channel_id) | ||
if challenge is None: | ||
await followup( | ||
( | ||
"Run this command from within a challenge thread, " | ||
"or provide the name of the challenge you wish to stop " | ||
"working on." | ||
) | ||
) | ||
return | ||
else: | ||
challenge = get_challenge_info(name=name) | ||
if challenge is None: | ||
await followup("No such challenge.") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The followup
function is not needed since interaction
will never be None
.
return | ||
|
||
solvers = [] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
embed = None | ||
num_fields = 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# If we reached Discord's maximum number of fields per | ||
# embed, we send the previous one and create a new one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maximum line length in this project is 88 chars
# If we reached Discord's maximum number of fields per | |
# embed, we send the previous one and create a new one. | |
# If we reached Discord's maximum number of fields per embed, we send the | |
# previous one and create a new one. |
Created "/ctf showsolvers" command.
Optional option: name
Description: