Skip to content
Merged
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
72 changes: 0 additions & 72 deletions party/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,78 +88,6 @@ async def on_submit(self, interaction: discord.Interaction):
await self.cog.signup_user(interaction, self.party_id, role, disabled_view=None, deferred=True)


class EditPartyModal(discord.ui.Modal):
"""Modal for editing party title and description."""

def __init__(self, party_id: str, party: dict, cog):
super().__init__(title="Edit Party")
self.party_id = party_id
self.cog = cog

# Title input
self.title_input = discord.ui.TextInput(
label="Party Title",
placeholder="Enter the party title",
default=party['name'],
required=True,
max_length=100,
)
self.add_item(self.title_input)

# Description input
self.description_input = discord.ui.TextInput(
label="Description",
placeholder="Enter party description (optional)",
default=party.get('description') or "",
required=False,
style=discord.TextStyle.paragraph,
max_length=2000,
)
self.add_item(self.description_input)

async def on_submit(self, interaction: discord.Interaction):
"""Handle the modal submission."""
# Defer immediately to prevent interaction timeout
await interaction.response.defer(ephemeral=True)

new_title = self.title_input.value.strip()
new_description = self.description_input.value.strip() or None

# Update the party data
async with self.cog.config.guild(interaction.guild).parties() as parties:
if self.party_id not in parties:
await interaction.followup.send("❌ Party not found.", ephemeral=True)
return

old_title = parties[self.party_id]['name']
old_description = parties[self.party_id].get('description')

parties[self.party_id]['name'] = new_title
parties[self.party_id]['description'] = new_description

# Update the party message
await self.cog.update_party_message(interaction.guild.id, self.party_id)

# Create modlog entry
reason = (
f"Party '{old_title}' (ID: {self.party_id}) edited.\n"
f"New title: {new_title}\n"
f"Old description: {old_description or 'None'}\n"
f"New description: {new_description or 'None'}"
)
await self.cog.create_party_modlog(
interaction.guild,
"party_edit",
interaction.user,
reason
)

await interaction.followup.send(
"✅ Party updated successfully!",
ephemeral=True
)


class CreatePartyModal(discord.ui.Modal):
"""Modal for creating a new party without command arguments."""

Expand Down
Loading