Skip to content

fix: check for the modteam role before reassigning the user's moderation role#2008

Closed
onerandomusername wants to merge 8 commits into
python-discord:mainfrom
onerandomusername:fix-issue-2007
Closed

fix: check for the modteam role before reassigning the user's moderation role#2008
onerandomusername wants to merge 8 commits into
python-discord:mainfrom
onerandomusername:fix-issue-2007

Conversation

@onerandomusername
Copy link
Copy Markdown
Contributor

closes #2007

@jchristgit jchristgit enabled auto-merge December 12, 2021 12:58
Comment thread bot/exts/moderation/modpings.py
auto-merge was automatically disabled December 14, 2021 20:18

Head branch was pushed to by a user without write access

Comment thread bot/exts/moderation/modpings.py Outdated
Comment thread bot/exts/moderation/modpings.py Outdated
@Xithrius Xithrius added a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve t: bug Something isn't working labels Dec 15, 2021
Copy link
Copy Markdown
Contributor

@TizzySaurus TizzySaurus left a comment

Choose a reason for hiding this comment

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

A few nitpicks. Main one I'd like to see implemented is the log.warning

Comment thread bot/exts/moderation/modpings.py
Comment thread bot/exts/moderation/modpings.py Outdated
Comment thread bot/exts/moderation/modpings.py Outdated
Comment thread bot/exts/moderation/modpings.py Outdated
Comment thread bot/exts/moderation/modpings.py
Comment thread bot/exts/moderation/modpings.py Outdated
Copy link
Copy Markdown
Contributor

@TizzySaurus TizzySaurus left a comment

Choose a reason for hiding this comment

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

Haven't tested anything, but aside from the backquote comment the code looks good 👍

Comment thread bot/exts/moderation/modpings.py Outdated
@ChrisLovering ChrisLovering added s: waiting for author Waiting for author to address a review or respond to a comment and removed s: needs review Author is waiting for someone to review and approve labels Apr 3, 2022
@wookie184 wookie184 added s: needs review Author is waiting for someone to review and approve and removed s: waiting for author Waiting for author to address a review or respond to a comment labels Aug 4, 2022
self.bot = bot
self._role_scheduler = Scheduler("ModPingsOnOff")
self._modpings_scheduler = Scheduler("ModPingsSchedule")
self.fetch_guild_task = self.bot.loop.create_task(self.fetch_guild())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This pattern of making a task and awaiting it in functions isn't needed anymore, since d.py added async cog_load loading. As it guarantees that the cog_load function is finished before the cog accepts any command/events.

So this task, an all usages of it can be safely deleted.

Comment on lines +139 to +140
await self.fetch_guild_task
if self.guild.get_role(Roles.mod_team) not in mod.roles:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why don't we just do guild = self.bot.get_guild(Guild.id) here and save all the task code?

# or it doesn't matter since this was called in a task.
# The logging statement above is enough to ensure that this was caught
# as with a logging level of WARNING, it will create a sentry issue.
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we delete them from pings_off_mods before returning? Does it matter?

@wookie184 wookie184 added s: waiting for author Waiting for author to address a review or respond to a comment and removed s: needs review Author is waiting for someone to review and approve labels Sep 11, 2022
@wookie184
Copy link
Copy Markdown
Contributor

Is this still necessary? I think the issue was fixed in 2b2dc95

@TizzySaurus
Copy link
Copy Markdown
Contributor

Is this still necessary? I think the issue was fixed in 2b2dc95

Without actually testing anything, it does indeed look like this issue has been fixed (which would mean this can be closed).

@wookie184
Copy link
Copy Markdown
Contributor

Since it's a bit more robust to have the check in the same place that the role is applied I think we could do this anyway.

I'll take this over and finish it off.

@wookie184 wookie184 self-assigned this Sep 21, 2022
@wookie184
Copy link
Copy Markdown
Contributor

Changed my mind again, I think this can just be closed :)

@wookie184 wookie184 closed this Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 2 - normal Normal Priority s: waiting for author Waiting for author to address a review or respond to a comment t: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modpings: role is assigned even if the user is no longer a mod

7 participants