Skip to content
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

cc: implement new DiagnoseCCTriggers command #1712

Merged
merged 4 commits into from
Aug 3, 2024

Conversation

jo3-l
Copy link
Contributor

@jo3-l jo3-l commented Aug 2, 2024

Review commit-by-commit.

Add a new debug command, DiagnoseCCTriggers, that lists all custom commands triggering on its input and identifies potential issues. The intent is for support members to instruct users to run DiagnoseCCTriggers in the event of custom commands not triggering as the user expects; we can also consider adding a note in the documentation and/or control panel pointing to this command where appropriate.

Sample output:
output from running the DiagnoseCCTriggers command

To implement DiagnoseCCTriggers, some light refactoring to enable code reuse was necessary (see first 3 commits.)

In the server, Henri proposed that, instead of a command, a control panel warning could be generated when there are conflicting triggers. Though such a warning would definitely be more discoverable, it is difficult to implement--requiring significantly more code than this PR--and near-impossible to make as robust as a command, so it would not catch all cases.) So we stick with the command here.

jo3-l added 4 commits August 2, 2024 11:50
This change unlocks using this function in a later commit (where we only have a guild ID, not the full guild data.) It's also more proper: ManageServerURL only needs the guild ID, so it need not be tied to dcmd.
The action of computing this limit is repeated throughout this file, so factor it out. Since we are using the limit for more than just messages, rename it appropriately.
Currently the comparator is internal to sortTriggeredCCs (which accepts a slice of *TriggeredCC), but we will need to sort a slice of custom commands directly to implement the debug command.

Extract the comparator out, document the priority order, and then refactor the implementation for clarity.

To prove that the old and new comparator implementations are functionally equivalent, see the following test: https://go.dev/play/p/NEUrG1wu0OI. It exhaustively enumerates all pairs of custom commands and ensures the old and new comparators agree.
@ashishjh-bst ashishjh-bst merged commit 8eae5d6 into botlabs-gg:dev Aug 3, 2024
1 check passed
galen8183 pushed a commit to galen8183/yagpdb that referenced this pull request Nov 12, 2024
* web: make ManageServerURL take guild ID directly

This change unlocks using this function in a later commit (where we only have a guild ID, not the full guild data.) It's also more proper: ManageServerURL only needs the guild ID, so it need not be tied to dcmd.

* cc: factor out CCActionExecLimit function

The action of computing this limit is repeated throughout this file, so factor it out. Since we are using the limit for more than just messages, rename it appropriately.

* cc: extract hasHigherPriority comparator

Currently the comparator is internal to sortTriggeredCCs (which accepts a slice of *TriggeredCC), but we will need to sort a slice of custom commands directly to implement the debug command.

Extract the comparator out, document the priority order, and then refactor the implementation for clarity.

To prove that the old and new comparator implementations are functionally equivalent, see the following test: https://go.dev/play/p/NEUrG1wu0OI. It exhaustively enumerates all pairs of custom commands and ensures the old and new comparators agree.

* cc: implement new DiagnoseCCTriggers command
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.

2 participants