Skip to content

fix some bug of ctf channel join button and show more information in /ctf_menu#17

Merged
UmmItKin merged 1 commit into
ICEDTEACTF:masterfrom
pictures2333:master
Jan 4, 2026
Merged

fix some bug of ctf channel join button and show more information in /ctf_menu#17
UmmItKin merged 1 commit into
ICEDTEACTF:masterfrom
pictures2333:master

Conversation

@pictures2333

Copy link
Copy Markdown
Contributor

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_menu commnd.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_menu command 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.

Comment thread src/cogs/ctf.py

# find category
category_name = "Incoming/Running CTF"
category_id = settings.CTF_CHANNEL_CATETORY_ID

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Suggested change
category_id = settings.CTF_CHANNEL_CATETORY_ID
category_id = settings.CTF_CHANNEL_CATEGORY_ID

Copilot uses AI. Check for mistakes.
Comment thread setup_env.sh
Comment on lines +130 to +131
read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATETORY_ID
if [ -n "$CTF_CHANNEL_CATETORY_ID" ]; then

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment thread setup_env.sh
Comment on lines +130 to +131
read -p " Paste your Discord Category ID: " CTF_CHANNEL_CATETORY_ID
if [ -n "$CTF_CHANNEL_CATETORY_ID" ]; then

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Suggested change
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"

Copilot uses AI. Check for mistakes.
Comment thread .env.example
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

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Suggested change
CTF_CHANNEL_CATETORY_ID=your_category_id_here
CTF_CHANNEL_CATEGORY_ID=your_category_id_here

Copilot uses AI. Check for mistakes.
Comment thread src/utils/ctf_api.py
"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()),

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
#"finish": int((datetime.now() + timedelta(days=settings.CTFTIME_SEARCH_DAYS)).timestamp()),

Copilot uses AI. Check for mistakes.
Comment thread setup_env.sh
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

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Suggested change
CTF_CHANNEL_CATETORY_ID=$CTF_CHANNEL_CATETORY_ID
CTF_CHANNEL_CATEGORY_ID=$CTF_CHANNEL_CATEGORY_ID

Copilot uses AI. Check for mistakes.
Comment thread src/utils/join_channel.py
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)

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread src/cogs/ctf.py
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)

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread setup_env.sh
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"

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Copilot uses AI. Check for mistakes.
Comment thread README.md
| `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` |

Copilot AI Jan 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling error in variable name: "CATETORY" should be "CATEGORY". This should match the corrected spelling in the configuration.

Suggested change
| `CTF_CHANNEL_CATETORY_ID` | Category id for CTF event channel creations | `1454642939559940329` |
| `CTF_CHANNEL_CATEGORY_ID` | Category id for CTF event channel creations | `1454642939559940329` |

Copilot uses AI. Check for mistakes.
@UmmItKin UmmItKin merged commit 5c7e509 into ICEDTEACTF:master Jan 4, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants