Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions party/party.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
# Discord embed field character limit
EMBED_FIELD_MAX_LENGTH = 1024

# Whether embed fields should be displayed inline
EMBED_FIELD_INLINE = False


class RoleSelectionModal(discord.ui.Modal):
"""Modal for selecting a role when signing up for a party (for freeform entry)."""
Expand Down Expand Up @@ -264,6 +261,7 @@ async def on_submit(self, interaction: discord.Interaction):
"channel_id": None,
"message_id": None,
"scheduled_time": scheduled_time,
"compact": False, # Default to not compact (inline=False)
}

# Initialize signups for each predefined role
Expand Down Expand Up @@ -1180,6 +1178,9 @@ async def create_party_embed(self, party: dict, guild: discord.Guild = None) ->
color=discord.Color.blue()
)

# Get the compact setting (inline fields) - default to False (not compact)
compact = party.get("compact", False)

# Show scheduled time if set
scheduled_time = party.get("scheduled_time")
if scheduled_time:
Expand All @@ -1188,7 +1189,7 @@ async def create_party_embed(self, party: dict, guild: discord.Guild = None) ->
embed.add_field(
name="📅 Scheduled Time",
value=f"<t:{ts}:F>\n(<t:{ts}:R>)",
inline=EMBED_FIELD_INLINE
inline=compact
)
except (ValueError, OSError):
pass
Expand All @@ -1209,7 +1210,7 @@ async def create_party_embed(self, party: dict, guild: discord.Guild = None) ->
else:
value = "-"

embed.add_field(name=role, value=value, inline=EMBED_FIELD_INLINE)
embed.add_field(name=role, value=value, inline=compact)

# Add roles that have signups but aren't in the predefined list (freeform roles)
for role, users in signups.items():
Expand All @@ -1219,11 +1220,11 @@ async def create_party_embed(self, party: dict, guild: discord.Guild = None) ->
value = ', '.join(user_mentions)
if len(value) > EMBED_FIELD_MAX_LENGTH:
value = value[:EMBED_FIELD_MAX_LENGTH-3] + "..."
embed.add_field(name=role, value=value, inline=EMBED_FIELD_INLINE)
embed.add_field(name=role, value=value, inline=compact)

# If no roles defined and no signups, show a message
if not roles and not any(users for users in signups.values()):
embed.add_field(name="Signups", value="-", inline=EMBED_FIELD_INLINE)
embed.add_field(name="Signups", value="-", inline=compact)

# Get owner name for footer
owner_name = await self._get_user_display_name(party['author_id'], guild)
Expand All @@ -1243,7 +1244,8 @@ async def party_create(
self,
ctx,
name: Optional[str] = None,
roles: Optional[str] = None
roles: Optional[str] = None,
compact: Optional[bool] = False
):
"""Create a new party with predefined roles.

Expand All @@ -1260,6 +1262,8 @@ async def party_create(
The name of the party
roles : Optional[str]
Space or comma-separated list of roles (e.g., "Tank Healer DPS" or "Tank, Healer, DPS")
compact : Optional[bool]
Display party in compact mode (inline fields). Default is False (not compact).

Examples:
- [p]party create (opens interactive modal)
Expand All @@ -1268,6 +1272,7 @@ async def party_create(
- [p]party create "Game Night" "Player1 Player2 Player3 Player4"
- [p]party create "PvP Team" "Warrior, Mage, Archer"
- [p]party create "Siege" "Siege Crossbow, Energy Shaper, GA"
- [p]party create "Compact Party" "Tank Healer DPS" True
"""
# If no arguments provided, show the modal
if name is None:
Expand Down Expand Up @@ -1352,6 +1357,7 @@ async def modal_button_callback(interaction: discord.Interaction):
"channel_id": None,
"message_id": None,
"scheduled_time": None,
"compact": compact, # Use the compact parameter from command
}

# Initialize signups for each predefined role
Expand Down Expand Up @@ -1522,7 +1528,9 @@ async def party_list(self, ctx):
f"{time_text}"
f"{link_text}"
)
embed.add_field(name=party["name"], value=value, inline=EMBED_FIELD_INLINE)
# Use party's compact setting, default to False
compact = party.get("compact", False)
embed.add_field(name=party["name"], value=value, inline=compact)

await ctx.send(embed=embed)

Expand Down Expand Up @@ -1887,7 +1895,8 @@ async def party_template_list(self, ctx):
roles_text = ', '.join(template['roles'])
if len(roles_text) > EMBED_FIELD_MAX_LENGTH:
roles_text = roles_text[:EMBED_FIELD_MAX_LENGTH - 3] + "..."
embed.add_field(name=label, value=roles_text, inline=EMBED_FIELD_INLINE)
# Templates list display is not compact by default
embed.add_field(name=label, value=roles_text, inline=False)

await ctx.send(embed=embed)

Expand Down Expand Up @@ -1945,6 +1954,7 @@ async def party_template_use(self, ctx, template_name: str, *, title: str):
"channel_id": None,
"message_id": None,
"scheduled_time": None,
"compact": False, # Default to not compact
}

# Initialize signups for each predefined role
Expand Down