Skip to content

Commit 94a9c95

Browse files
[guild] balls drop configuration (#817)
* balls drop configuration * Update ballsdex/packages/guildconfig/cog.py Co-authored-by: dormieriancitizen <111535275+dormieriancitizen@users.noreply.github.com> --------- Co-authored-by: dormieriancitizen <111535275+dormieriancitizen@users.noreply.github.com>
1 parent a4ad1cd commit 94a9c95

5 files changed

Lines changed: 50 additions & 3 deletions

File tree

admin_panel/bd_models/admin/guild.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def player(self, obj: BallInstance):
7070

7171
@admin.register(GuildConfig)
7272
class GuildAdmin(admin.ModelAdmin):
73-
list_display = ("guild_id", "spawn_channel", "enabled", "silent", "blacklisted")
74-
list_filter = ("enabled", "silent", BlacklistedListFilter)
73+
list_display = ("guild_id", "spawn_channel", "enabled", "silent", "manual_drop_enabled", "blacklisted")
74+
list_filter = ("enabled", "silent", "manual_drop_enabled", BlacklistedListFilter)
7575
show_facets = admin.ShowFacets.NEVER # type: ignore
7676

7777
search_fields = ("guild_id", "spawn_channel")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 6.0 on 2026-07-05 17:45
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [("bd_models", "0017_ballgroup")]
8+
9+
operations = [
10+
migrations.AddField(
11+
model_name="guildconfig",
12+
name="manual_drop_enabled",
13+
field=models.BooleanField(
14+
default=True, help_text="Whether players are allowed to use the drop command in this server"
15+
),
16+
)
17+
]

admin_panel/bd_models/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ class GuildConfig(models.Model):
8282
silent = models.BooleanField(
8383
help_text="Whether the responses of guesses get sent as ephemeral or not", default=False
8484
)
85+
manual_drop_enabled = models.BooleanField(
86+
help_text="Whether players are allowed to use the drop command in this server", default=True
87+
)
8588
admin_command_synced = models.BooleanField(
8689
help_text="True if slash admin commands are present in this server", default=False, editable=False
8790
)

ballsdex/packages/balls/cog.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from ballsdex.core.utils.utils import can_mention, inventory_privacy, is_staff
2727
from bd_models.enums import DonationPolicy
28-
from bd_models.models import BallInstance, Player, Special, Trade, TradeObject, balls, groups
28+
from bd_models.models import BallInstance, GuildConfig, Player, Special, Trade, TradeObject, balls, groups
2929
from settings.models import settings
3030

3131
from .bulk_give_selector import BulkGiveSelector
@@ -535,6 +535,13 @@ async def drop(
535535
if not countryball:
536536
return
537537

538+
config = await GuildConfig.objects.aget_or_none(guild_id=interaction.guild_id)
539+
if config and not config.manual_drop_enabled:
540+
await interaction.response.send_message(
541+
"The drop command is currently disabled in this server.", ephemeral=True
542+
)
543+
return
544+
538545
cog = cast("CountryBallsSpawner | None", self.bot.get_cog("CountryBallsSpawner"))
539546
if not cog or not interaction.guild_id or cog.cache.get(interaction.guild_id) != interaction.channel_id:
540547
await interaction.response.send_message(

ballsdex/packages/guildconfig/cog.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,25 @@ async def disable(self, interaction: discord.Interaction["BallsDexBot"]):
151151
f"spawning channel set. Please configure one with {config_cmd}."
152152
)
153153

154+
@app_commands.command()
155+
@app_commands.checks.has_permissions(manage_guild=True)
156+
@app_commands.checks.bot_has_permissions(send_messages=True)
157+
async def toggledrop(self, interaction: discord.Interaction["BallsDexBot"]):
158+
"""
159+
Allow or disallow players from using the drop command in this server.
160+
"""
161+
config, created = await GuildConfig.objects.aget_or_create(guild_id=interaction.guild_id)
162+
config.manual_drop_enabled = not config.manual_drop_enabled # type: ignore
163+
await config.asave()
164+
if config.manual_drop_enabled:
165+
await interaction.response.send_message(
166+
f"Players can now use the drop command to manually spawn {settings.plural_collectible_name}."
167+
)
168+
else:
169+
await interaction.response.send_message(
170+
f"Players can no longer use the drop command to manually spawn {settings.plural_collectible_name}."
171+
)
172+
154173
@app_commands.command()
155174
@app_commands.checks.has_permissions(manage_guild=True)
156175
async def status(self, interaction: discord.Interaction["BallsDexBot"]):
@@ -181,6 +200,7 @@ async def status(self, interaction: discord.Interaction["BallsDexBot"]):
181200

182201
embed.add_field(name="Channel", value=channel.mention, inline=True)
183202
embed.add_field(name="Status", value="Enabled" if config.enabled else "Disabled", inline=True)
203+
embed.add_field(name="Drop command", value="Enabled" if config.manual_drop_enabled else "Disabled", inline=True)
184204

185205
def tick(granted: bool) -> str:
186206
return "\N{WHITE HEAVY CHECK MARK}" if granted else "\N{CROSS MARK}"

0 commit comments

Comments
 (0)