Skip to content

refactor: introduce commands.Cog#4

Merged
Nanahuse merged 2 commits intomainfrom
refactor/remove_global_variable
Dec 1, 2025
Merged

refactor: introduce commands.Cog#4
Nanahuse merged 2 commits intomainfrom
refactor/remove_global_variable

Conversation

@Nanahuse
Copy link
Owner

@Nanahuse Nanahuse commented Dec 1, 2025

src/countdown_cog.py is renamed from src/countdown_bot.py. Its logic is not changed.

main.py load all environment variables.

src/log_handler.py
bot argument is removed. Because it can load from ctx

Copilot AI review requested due to automatic review settings December 1, 2025 10:04
Copy link

Copilot AI left a comment

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 refactors the Discord bot codebase from a module-level command pattern to a more modular Cog-based architecture. The main countdown bot functionality is moved from src/countdown_bot.py to src/countdown_cog.py as a commands.Cog subclass, while bot initialization is centralized in src/main.py. The LogHandler class is also refactored to store the bot reference internally rather than requiring it as a parameter to each method call.

Key changes:

  • Introduced CountdownCog class to encapsulate countdown commands using the discord.py Cog pattern
  • Centralized bot initialization and configuration in main.py
  • Refactored LogHandler to store bot reference in constructor, simplifying method signatures

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main.py Added bot initialization, logger setup, and cog registration logic
src/countdown_cog.py New file containing CountdownCog class with rc and vrc commands migrated from countdown_bot.py
src/countdown_bot.py Deleted file - functionality moved to countdown_cog.py
src/log_handler.py Refactored to accept bot in constructor and removed bot parameter from logging methods
src/load_env.py Changed load_bot_token() to return None instead of raising exception when token not found
uv.lock Updated package name from "workspace" to "racebot"
pyproject.toml Added docstring-code-format configuration for Ruff
.devcontainer/devcontainer.json Added editor settings for formatting and linting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Copy link
Contributor

Copilot AI commented Dec 1, 2025

@Nanahuse I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

@Nanahuse Nanahuse merged commit cd5a640 into main Dec 1, 2025
1 check passed
@Nanahuse Nanahuse deleted the refactor/remove_global_variable branch December 1, 2025 12:22
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