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
[Warnings]Make it possible to add reason with unwarn #3490
[Warnings]Make it possible to add reason with unwarn #3490
Conversation
Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com>
Co-Authored-By: Draper <27962761+Drapersniper@users.noreply.github.com>
This is a review for the Code and not functionality:
LGTM (Can't check functionality atm)
redbot/cogs/warnings/warnings.py
Outdated
msg = _("That is not a registered reason.") | ||
if custom_allowed: | ||
reason_type = {"description": reason} | ||
elif ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually stating the valid reasons, when custom_allowed
is disallowed and reason.lower() not in registered_reasons
would be more user friendly (something along the lines of "Please use one of the following: ...")
Right now if reason.lower() not in registered_reasons and not custom_allowed
this just fails silently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look at this when I return home later today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would then require to be edited in the warn command as well. My knowledge in string formatting is limited (everyone tells me my code is to slow) that I'd rather leave that up to someone else as it also doesn't really fit in this PR in my opinion. If you really want to see this included I'll need some guidance via discord.
I'm guessing that reason_lower
is a list of strings that in one way ore another can be concatinated and passed to an embed which is then sent to the user. If we exceed the embed limit with the amount of registered reasons that's going to require some logic I don't know how to code and I'm not really sure if it's worth it at that point. Leaving it with just the instructions on how to enable custom warnings seems reasonable to me.
Are they supposed to not report anything? Do I need to do something? |
redbot/cogs/warnings/warnings.py
Outdated
else: | ||
reason_type = registered_reasons[reason.lower()] | ||
if reason_type is None: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we should return a user friendly message when a valid reason is not present, just silently doing nothing is very confusing imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If another QA/Core-dev disagrees let me know and i'll review this as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree we shouldn't fail silently, though I don't think we should list all registered reasons, especially not in scope of this PR.
I still think that registered warn reasons shouldn't be used for unwarn - they will simply not make sense as unwarn reasons. I think allowing any text as unwarn reason is enough but I guess there's also the option of registering unwarn reasons. |
I think just removing the use of registered reasons for unwarn is the way forward with this. You guys let me know if that's what you want me to do. |
…y if the command author was an admin, guild owner or bot owner.
Okay now that we return a message when reason_type is None I’m more okay with this. Although jack made a point And not sure how strongly he feels about this one @jack1142 do you think removing the usage of the built in reason type is important enough here?
@Dav-Git after additional discussion, we decided that |
redbot/cogs/warnings/warnings.py
Outdated
@@ -433,14 +462,15 @@ def __init__(self, bot: Red): | |||
await member_settings.total_points.set(current_point_count) | |||
user_warnings.pop(warn_id) | |||
try: | |||
reason_msg = "{description}".format(description=reason_type["description"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be (though this part might not even exist after allowing any reason):
reason_msg = "{description}".format(description=reason_type["description"]) | |
reason_msg = reason_type["description"] |
Sounds good to me. I'll remove it for both commands. Maybe the commands to set the warn reasons are pending removal too though? Especially since the reasons then no longer server a purpose. |
Correction, I misread that, allowing any reason for just unwarn |
Looks like I'm gonna review this PR after all, only one change should be needed here before approval :)
Co-Authored-By: jack1142 <6032823+jack1142@users.noreply.github.com>
Type
Bugfix
Enhancement
[X] New feature
Description of the changes
This closes #3093 .
This overwrites #3441 because I'm stupid and deleted the fork.