Skip to content

refactor(command): refactor close command#249

Merged
Akinator31 merged 2 commits intomainfrom
245-refactor-close-command
Nov 24, 2025
Merged

refactor(command): refactor close command#249
Akinator31 merged 2 commits intomainfrom
245-refactor-close-command

Conversation

@Akinator31
Copy link
Copy Markdown
Member

This pull request refactors and improves the scheduled thread closure logic in both the slash and text command implementations. The main changes are the extraction of a reusable format_duration function, improved user feedback when replacing an existing scheduled closure, and a significant simplification of how category and permission information is determined and passed around. Additionally, the scheduling logic for closures has been centralized for maintainability.

User feedback improvements:

  • Users are now notified with a human-readable duration when their scheduled closure replaces an existing one, using the new format_duration function for consistency.

Code simplification and maintainability:

  • Category ID, category name, and permissions are now determined inline using Discord API calls, removing several helper functions and reducing duplicated code in both slash and text command paths.

Scheduling logic refactor:

  • The thread closure scheduling task has been moved to a centralized schedule_one function, replacing the previous inlined and nested tokio::spawn logic, making it easier to maintain and extend.

General code improvements:

  • All user-facing duration formatting now uses the new format_duration function for consistency and readability.
  • Minor improvements to async message sending, reducing unnecessary variable assignments and improving code clarity.

These changes improve user experience, reduce code duplication, and make the scheduling logic easier to understand and maintain.

@Akinator31 Akinator31 self-assigned this Nov 24, 2025
@Akinator31 Akinator31 linked an issue Nov 24, 2025 that may be closed by this pull request
@Akinator31 Akinator31 merged commit de126c8 into main Nov 24, 2025
9 checks passed
@Akinator31 Akinator31 deleted the 245-refactor-close-command branch November 24, 2025 09:44
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.

Refactor close command

1 participant