Skip to content

Commit 86a157b

Browse files
Reimplement admin channel ids for inv privacy bypass (#734)
1 parent f4628fa commit 86a157b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

admin_panel/settings/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,17 @@ def currency_enabled(self) -> bool:
119119

120120
# admin command control
121121
admin_channel_ids = models.TextField(
122-
help_text="Semicolon-delimited list of channel IDs where admin commands can be used. Ignored for owners. "
122+
help_text="Semicolon-delimited channel IDs where staff may bypass inventory privacy. Ignored for owners."
123123
"If empty, then admin commands can be used everywhere.",
124124
validators=(RegexValidator(COLON_IDS_RE, message="The IDs must be semicolon-separated"),),
125125
blank=True,
126126
default="",
127127
)
128+
129+
@cached_property
130+
def inv_privacy_bypass_ids(self) -> list[int]:
131+
return [] if self.admin_channel_ids is None else [int(x) for x in self.admin_channel_ids.split(";") if x]
132+
128133
webhook_logging = models.URLField(
129134
help_text="An optional Discord Webhook where admin events will be logged.",
130135
validators=(RegexValidator(DISCORD_WEBHOOK_RE, message="Only Discord webhooks are supported."),),

ballsdex/core/utils/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from bd_models.enums import PrivacyPolicy
66
from bd_models.models import Player
7+
from settings.models import settings
78

89
from .checks import get_user_for_check
910

@@ -35,6 +36,7 @@ async def is_staff(interaction: discord.Interaction["BallsDexBot"], *perms: str)
3536
return user
3637
if not user.is_staff:
3738
return False
39+
3840
return await user.ahas_perms(perms)
3941

4042

@@ -70,7 +72,9 @@ async def inventory_privacy(
7072
if interaction.user.id == player.discord_id:
7173
return True
7274
if await is_staff(interaction):
73-
return True
75+
if settings.inv_privacy_bypass_ids and interaction.channel_id in settings.inv_privacy_bypass_ids:
76+
return True
77+
7478
if privacy_policy == PrivacyPolicy.DENY:
7579
await interaction.followup.send("This user has set their inventory to private.", ephemeral=True)
7680
return False

0 commit comments

Comments
 (0)