class SubmitModal(DesignerModal):
def __init__(self, console: str):
super().__init__(title=f"{console} Submission")
self.console = console
self.winner = discord.ui.Label(
label="Winner",
item=discord.ui.RadioGroup(
options=[
discord.RadioGroupOption(label="Red Team", value="Red"),
discord.RadioGroupOption(label="Blue Team", value="Blue"),
],
required=True,
),
description="Select the winning team for this match."
)
self.gamemode = Label(
"Gamemode",
Select(
placeholder="Select the gamemode",
options=[
discord.SelectOption(label="Blast", value="Blast"),
discord.SelectOption(label="SFA", value="SFA"),
discord.SelectOption(label="CS", value="CS"),
discord.SelectOption(label="GA", value="GA"),
],
required=True,
min_values=1,
max_values=1
)
)
self.summary = Label(
"Summary",
TextInput(
placeholder="Match summary",
style=discord.InputTextStyle.long,
required=True,
),
description="Summary of each game in the match",
)
self.evidence = Label(
"Evidence",
FileUpload(
required=True,
max_values=3
),
description="Leaderboard screenshots",
)
self.add_item(self.winner)
self.add_item(self.gamemode)
self.add_item(self.summary)
self.add_item(self.evidence)
async def callback(self, interaction: discord.Interaction):
await interaction.respond("Submission received and posted to the review thread.", ephemeral=True)
winner = self.children[0].item.value
gamemode = self.children[1].item.values[0]
summary = self.children[2].item.value
evidence_files = self.children[3].item.values
submitted_at = discord.utils.utcnow()
unix_ts = int(submitted_at.timestamp())
timestamp_text = f"Submitted at <t:{unix_ts}:F> (<t:{unix_ts}:R>)"
components: list[discord.ui.Item[discord.ui.DesignerView]] = [
discord.ui.Container(
discord.ui.TextDisplay(content=f"## {self.console} Submission"),
discord.ui.TextDisplay(content=f"### {winner} Team Win"),
discord.ui.TextDisplay(content=f"### Gamemode: {gamemode}"),
discord.ui.Separator(divider=True, spacing=discord.SeparatorSpacingSize.small),
discord.ui.TextDisplay(content=f"### Summary\n\n{summary}"),
discord.ui.MediaGallery(
*[MediaGalleryItem(url=file.url) for file in evidence_files]
),
discord.ui.Separator(divider=True, spacing=discord.SeparatorSpacingSize.small),
discord.ui.TextDisplay(content=timestamp_text),
color=discord.Color(15275799 if winner == "Red" else 3447003),
),
]
view = discord.ui.DesignerView(*components)
thread = interaction.guild.get_thread(1476127160229171240)
await thread.send(view=view)
this is really slow are processing and sending to the thread, is there a way to speed it up and...
is there a way to limit the file types that can be uploaded?