Skip to content

Commit

Permalink
Fix clearwarns
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenChen committed Jan 17, 2025
1 parent 88963bf commit 60c93d0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utils/database/warns.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ async def delete_deleted_warning(self, warn_id: int) -> int:
async def delete_all_warnings(self, user_id: int, deleter: int, reason: 'Optional[str]') -> int:
"""Delete all warnings for a user id."""
assert isinstance(user_id, int)
res = await self._update('warns',
{'deletion_time': datetime.now(), 'deletion_reason': reason, 'deleter': deleter},
user_id=user_id)
query = "UPDATE warns SET deletion_time = $1, deletion_reason = $2, deleter = $3, state = $4 WHERE user_id = $5 AND state not in (1,2)"
args = (datetime.now(), reason, deleter, 1, user_id)
async with self.pool.acquire() as conn:
async with conn.transaction():
res = await conn.execute(query, *args)
if res:
self.log.debug('Removed all warnings for %d', user_id)
return res
Expand Down

0 comments on commit 60c93d0

Please sign in to comment.