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

Give help thread owners ability to use !title command. #2772

Closed
wants to merge 4 commits into from

Conversation

swfarnsworth
Copy link
Member

Previously, only staff members could use the command. The implementation is a bit fragile as it depends on short-circuiting commands.has_any_role(constants.Roles.helpers).predicate(ctx) in the case that the user is not the OP, which would raise an exception for non-staffers instead of returning False.

image

Previously, only staff members could use the command. The implementation is a bit fragile as it depends on short-circuiting `commands.has_any_role(constants.Roles.helpers).predicate(ctx)` in the case that the user is not the OP, which would raise an exception for non-staffers instead of returning False.

if (
ctx.author.id == ctx.channel.owner_id
or await commands.has_any_role(constants.Roles.helpers).predicate(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could use this utility function? Suggested by @TizzySaurus

Suggested change
or await commands.has_any_role(constants.Roles.helpers).predicate(ctx)
or has_any_role_check(ctx, constants.Roles.helpers)

has_any_role_check would need to be imported from bot.utils.checks import has_any_role_check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that solves the "The implementation is a bit fragile as it depends on short-circuiting ..." problem, then I support it.

Copy link
Member

@shenanigansd shenanigansd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for @Robin5605 's suggestion but LGTM

@swfarnsworth
Copy link
Member Author

I'm going to refactor and push another commit--do not merge yet.

The latter will raise an error instead of returning False, whereas the former will return a bool in either case, which is more appropriate here.
@swfarnsworth
Copy link
Member Author

image

image

Comment on lines +115 to 118
if not (user_is_op or user_is_staff):
return

await ctx.channel.edit(name=title)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not (user_is_op or user_is_staff):
return
await ctx.channel.edit(name=title)
if user_is_op or user_is_staff:
await ctx.channel.edit(name=title)

I think not using a negative here makes the intent clearer

@ChrisLovering
Copy link
Member

No longer needed since #2774 was merged.

@ChrisLovering ChrisLovering deleted the swfarnsworth/title-command-for-op branch November 1, 2023 08:31
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.

4 participants