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

Automatically apply pardoned timeouts upon rejoining the server #2963

Open
shtlrs opened this issue Mar 19, 2024 · 3 comments
Open

Automatically apply pardoned timeouts upon rejoining the server #2963

shtlrs opened this issue Mar 19, 2024 · 3 comments
Labels
a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 3 - low Low Priority status: approved The issue has received a core developer's approval t: enhancement Changes or improvements to existing features

Comments

@shtlrs
Copy link
Member

shtlrs commented Mar 19, 2024

This has been originally raised by @vivekashok1221 here

The current scenario is this

Scenario

  1. A user is muted for 4 days
  2. The user leaves the server
  3. Someone with the right perms pardons the unmute
  4. The user rejoins the server

Problem

Step 3 will only pardon the infraction in our database, but the native discord timeout will still remain in place since we cannot edit that when a user is not a Member of our server.
This means that someone would have to manually unmute the user.

@shtlrs shtlrs added p: 3 - low Low Priority t: enhancement Changes or improvements to existing features labels Mar 19, 2024
@lxnn lxnn self-assigned this Mar 30, 2024
@wookie184 wookie184 changed the title Automatically apply pardonned timeouts upon rejoining the server Automatically apply pardoned timeouts upon rejoining the server Apr 16, 2024
@wookie184
Copy link
Contributor

This should probably just require adding something like

elif <user_has_timeout>:
    <remove_user_timeout>

here

async def on_member_join(self, member: Member) -> None:
"""
Apply active timeout infractions for returning members.
This is needed for users who might have had their infraction edited in our database but not in Discord itself.
"""
active_timeouts = await self.bot.api_client.get(
endpoint="bot/infractions",
params={"active": "true", "type": "timeout", "user__id": member.id}
)
if active_timeouts:
timeout_infraction = active_timeouts[0]
expiry = arrow.get(timeout_infraction["expires_at"], tzinfo=UTC).datetime.replace(second=0, microsecond=0)
if member.is_timed_out() and expiry == member.timed_out_until.replace(second=0, microsecond=0):
return
reason = f"Applying active timeout for returning member: {timeout_infraction['id']}"
async def action() -> None:
await member.edit(timed_out_until=expiry, reason=reason)
await self.reapply_infraction(timeout_infraction, action)

@wookie184 wookie184 added a: moderation Related to community moderation functionality: (moderation, defcon, verification) status: approved The issue has received a core developer's approval labels May 24, 2024
@wookie184
Copy link
Contributor

@lxnn Hi, any update on this?

@lxnn lxnn removed their assignment Jun 5, 2024
@lxnn
Copy link
Contributor

lxnn commented Jun 5, 2024

Hi @wookie184, I'm so sorry. I only got as far as starting to familiarise myself with the codebase to work on this issue and then it fell by the way-side. I've un-assigned myself from the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: moderation Related to community moderation functionality: (moderation, defcon, verification) p: 3 - low Low Priority status: approved The issue has received a core developer's approval t: enhancement Changes or improvements to existing features
Projects
None yet
Development

No branches or pull requests

3 participants