Fix defcon having wrong text when disabling.#541
Merged
Conversation
#### Closes python-discord#539 This pull request fixes the issue for wrong status in the embed, as well as unifying certains if else to prevent similar future errors. Most notable code is here: ```python log_msg = f"**Staffer:** {actor} (`{actor.id}`)\n" if change.lower() == "enabled": icon = Icons.defcon_enabled color = Colours.soft_green status_msg = "DEFCON enabled" log_msg += f"**Days:** {self.days.days}\n\n" elif change.lower() == "disabled": icon = Icons.defcon_disabled color = Colours.soft_red status_msg = "DEFCON enabled" elif change.lower() == "updated": icon = Icons.defcon_updated color = Colour.blurple() status_msg = "DEFCON updated" log_msg += f"**Days:** {self.days.days}\n\n" ``` To remedy this issue, the class will now have a private class variable ```py _defcon_log_info: Dict[str, Tuple] = { 'enabled': (Icons.defcon_enabled, Colours.soft_green, "**Days:** {days}\n\n"), 'disabled': (Icons.defcon_disabled, Colours.soft_red, ""), 'updated': (Icons.defcon_updated, Colour.blurple(), "**Days:** {days}\n\n"), } ``` Another big change is the introduction of `_defcon_action` to unify the process all defcon actions has to go through: - Try to do the action. - Log error if there is any. - Send log message.
MarkKoz
requested changes
Oct 19, 2019
- Further unify defcon actions in `_defcon_action` - Thanks to Mark's suggestions. - Changed from a Dict to an Enum for defcon log info.
MarkKoz
requested changes
Oct 20, 2019
- Renamed `DefconInfoLog` to `Action` - Added `ActionInfo` namedtuple. - Use `Action` consistently for `_defcon_action()` and `send_defcon_log()`
MarkKoz
requested changes
Oct 21, 2019
- Remove the unneccessary `get_info()` method of Enum `Action`. - Pass Enum `Action` directly to `build_defcon_msg()` and `send_defcon_log()` - Right now, only `_defcon_action()` is using them.
MarkKoz
requested changes
Oct 21, 2019
- Update docstrings for `build_defcon_msg()` and `send_defcon_log()` - It is now taking in an `Action` directly instead of a string.
MarkKoz
approved these changes
Oct 21, 2019
- Now it will only show the amount of days. - Quality of Life: Also show `day` instead of `days` when it's just 1 day.
sco1
approved these changes
Oct 21, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #539
This pull request fixes the issue for wrong status in the embed, as well as unifying certains if else to prevent similar future errors.
Most notable code is here:
To remedy this issue, the class will now have a
private class variableEnum( Thanks to @MarkKoz for the suggestions )Another big change is the introduction of
_defcon_actionto unify the process all defcon actions has to go through: