fix some bug of ctf channel join button and show more information in /ctf_menu#17
Conversation
fix(bgtask_interaction): fix same event_id of join channel button on ctf event notification fix(ctf_api): search time feat: get channel / category by name -> by id docs(README): change descriptions about envrionment variables and data storage
There was a problem hiding this comment.
Pull request overview
This PR addresses several issues with CTF channel management by migrating from name-based to ID-based lookups for Discord channels/categories, fixing a time range bug in the CTF API, and enhancing the /ctf_menu command with status indicators. The changes also add fastapi and uvicorn dependencies, though their usage is not evident in the reviewed code.
Key changes:
- Migration from name-based to ID-based Discord channel/category lookups to improve reliability
- Removal of time range filter in CTF API by commenting out the "finish" parameter
- Enhancement of
/ctf_menucommand with emoji markers showing channel creation status and running events
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
src/config.py |
Removes CTFTIME_SEARCH_DAYS and replaces ANNOUNCEMENT_CHANNEL_NAME with ID-based configuration variables |
src/utils/ctf_api.py |
Comments out the "finish" parameter to remove time range filtering for CTF event searches |
src/utils/join_channel.py |
Updates category lookup from name-based to ID-based approach |
src/cogs/ctf.py |
Updates category lookup and enhances /ctf_menu with status indicators (⭐️ for channel created, 🏃 for running CTF) |
src/cogs/bgtask_interactions.py |
Refactors announcement channel lookup to use ID-based approach and extracts event_id for button custom_id |
setup_env.sh |
Updates setup script to prompt for channel and category IDs instead of names |
pyproject.toml |
Adds fastapi and uvicorn dependencies |
uv.lock |
Updates lock file with new dependency resolution including fastapi, uvicorn, and their transitive dependencies |
README.md |
Updates documentation to reflect ID-based configuration |
.env.example |
Updates example environment file with ID-based variable names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # find category | ||
| category_name = "Incoming/Running CTF" | ||
| category_id = settings.CTF_CHANNEL_CATETORY_ID |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| category_id = settings.CTF_CHANNEL_CATETORY_ID | |
| category_id = settings.CTF_CHANNEL_CATEGORY_ID |
| read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATETORY_ID | ||
| if [ -n "$CTF_CHANNEL_CATETORY_ID" ]; then |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATETORY_ID | |
| if [ -n "$CTF_CHANNEL_CATETORY_ID" ]; then | |
| read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATEGORY_ID | |
| if [ -n "$CTF_CHANNEL_CATEGORY_ID" ]; then |
| read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATETORY_ID | ||
| if [ -n "$CTF_CHANNEL_CATETORY_ID" ]; then |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATETORY_ID | |
| if [ -n "$CTF_CHANNEL_CATETORY_ID" ]; then | |
| read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATEGORY_ID | |
| if [ -n "$CTF_CHANNEL_CATEGORY_ID" ]; then | |
| # Backward compatibility: keep old misspelled variable name in sync | |
| CTF_CHANNEL_CATETORY_ID="$CTF_CHANNEL_CATEGORY_ID" |
| CHECK_INTERVAL_MINUTES=30 | ||
| ANNOUNCEMENT_CHANNEL_NAME=your_channel_name_here | ||
| ANNOUNCEMENT_CHANNEL_ID=your_channel_id_here | ||
| CTF_CHANNEL_CATETORY_ID=your_category_id_here |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| CTF_CHANNEL_CATETORY_ID=your_category_id_here | |
| CTF_CHANNEL_CATEGORY_ID=your_category_id_here |
| "limit": 20, | ||
| "start": int(datetime.now().timestamp()), | ||
| "finish": int((datetime.now() + timedelta(days=settings.CTFTIME_SEARCH_DAYS)).timestamp()), | ||
| #"finish": int((datetime.now() + timedelta(days=settings.CTFTIME_SEARCH_DAYS)).timestamp()), |
There was a problem hiding this comment.
Commented-out code should be removed rather than left in the codebase. The "finish" parameter is commented out which removes the time range filter for CTF event searches. If this is intentional to fetch all future events, the parameter should be removed entirely. If the parameter is still needed, it should be properly implemented. Leaving commented code creates confusion about the intended behavior.
| #"finish": int((datetime.now() + timedelta(days=settings.CTFTIME_SEARCH_DAYS)).timestamp()), |
| CHECK_INTERVAL_MINUTES=$CHECK_INTERVAL_MINUTES | ||
| ANNOUNCEMENT_CHANNEL_NAME=$ANNOUNCEMENT_CHANNEL_NAME | ||
| ANNOUNCEMENT_CHANNEL_ID=$ANNOUNCEMENT_CHANNEL_ID | ||
| CTF_CHANNEL_CATETORY_ID=$CTF_CHANNEL_CATETORY_ID |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| CTF_CHANNEL_CATETORY_ID=$CTF_CHANNEL_CATETORY_ID | |
| CTF_CHANNEL_CATEGORY_ID=$CTF_CHANNEL_CATEGORY_ID |
| category = discord.utils.get(interaction.guild.categories, id=category_id) | ||
| if category is None: | ||
| await interaction.followup.send(content=f"Category '{category_name}' not found.", ephemeral=True) | ||
| await interaction.followup.send(content=f"Category id={category_id} not found", ephemeral=True) |
There was a problem hiding this comment.
The error message incorrectly states the category should have "name=category_name" when the code is now using ID-based lookup with "id=category_id". The error message should be updated to reflect that category lookup is now based on ID, not name.
| category = discord.utils.get(interaction.guild.categories, id=category_id) | ||
| if category is None: | ||
| await interaction.followup.send(content=f"Category '{category_name}' not found.", ephemeral=True) | ||
| await interaction.followup.send(content=f"Category id={category_id} not found", ephemeral=True) |
There was a problem hiding this comment.
The error message incorrectly states the category should have "name=category_name" when the code is now using ID-based lookup with "id=category_id". The error message should be updated to reflect that category lookup is now based on ID, not name.
| echo " Check Interval: $CHECK_INTERVAL_MINUTES minutes" | ||
| echo " Announcement Channel Name: $ANNOUNCEMENT_CHANNEL_NAME" | ||
| echo " Announcement Channel ID: $ANNOUNCEMENT_CHANNEL_ID" | ||
| echo " CTF Channel Category ID: $CTF_CHANNEL_CATETORY_ID" |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| | `CHECK_INTERVAL_MINUTES` | How often to check for new CTFs | `30` (default) | | ||
| | `ANNOUNCEMENT_CHANNEL_ID` | Channel name for announcements | `ctf-announcements` | | ||
| | `ANNOUNCEMENT_CHANNEL_ID` | Channel id for announcements | `911612541829009418` | | ||
| | `CTF_CHANNEL_CATETORY_ID` | Category id for CTF event channel creations | `1454642939559940329` | |
There was a problem hiding this comment.
Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.
| | `CTF_CHANNEL_CATETORY_ID` | Category id for CTF event channel creations | `1454642939559940329` | | |
| | `CTF_CHANNEL_CATEGORY_ID` | Category id for CTF event channel creations | `1454642939559940329` | |
This pull request fixes the bug of join channel button on new ctf event notification (same event_id), the time range bug in ctf_api and shows more information like ctf channel created and now running in
/ctf_menucommnd.