Skip to content

Commit 3e10b0c

Browse files
committed
Use voice_mute and voice_ban to determine voice_gate
Previously only voice_ban was used, but now having either of these infractions should mean the user is blocked from reciving the role.
1 parent 7056e7f commit 3e10b0c

File tree

1 file changed

+6
-8
lines changed
  • pydis_site/apps/api/viewsets/bot

1 file changed

+6
-8
lines changed

pydis_site/apps/api/viewsets/bot/user.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typing
22
from collections import OrderedDict
33

4-
from django.core.exceptions import ObjectDoesNotExist
4+
from django.db.models import Q
55
from rest_framework import status
66
from rest_framework.decorators import action
77
from rest_framework.pagination import PageNumberPagination
@@ -261,12 +261,10 @@ def metricity_data(self, request: Request, pk: str = None) -> Response:
261261
"""Request handler for metricity_data endpoint."""
262262
user = self.get_object()
263263

264-
try:
265-
Infraction.objects.get(user__id=user.id, active=True, type="voice_ban")
266-
except ObjectDoesNotExist:
267-
voice_banned = False
268-
else:
269-
voice_banned = True
264+
has_voice_infraction = Infraction.objects.filter(
265+
Q(user__id=user.id, active=True),
266+
Q(type="voice_ban") | Q(type="voice_mute")
267+
).exists()
270268

271269
with Metricity() as metricity:
272270
try:
@@ -275,7 +273,7 @@ def metricity_data(self, request: Request, pk: str = None) -> Response:
275273
data["total_messages"] = metricity.total_messages(user.id)
276274
data["activity_blocks"] = metricity.total_message_blocks(user.id)
277275

278-
data["voice_banned"] = voice_banned
276+
data["voice_gate_blocked"] = has_voice_infraction
279277
return Response(data, status=status.HTTP_200_OK)
280278
except NotFoundError:
281279
return Response(dict(detail="User not found in metricity"),

0 commit comments

Comments
 (0)