#πŸ”’ Modal saying "Something went wrong. Try again." when nothing is wrong.

7 messages Β· Page 1 of 1 (latest)

sleek cloud
#

So, I'm making this bot for someone, they want a trial log type thing. But, the modal is saying "Something went wrong. Try again." When I'm getting no output errors, and it still does what I asks and sends it to the channel needed.

random perchBOT
#

@sleek cloud

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sleek cloud
#
import asyncio
import discord
from discord import ui, app_commands
from datetime import datetime

class client(discord.Client):
    def __init__(self):
        super().__init__(intents=discord.Intents.all())
        self.synced = False

    async def on_ready(self):
        await self.wait_until_ready()
        if not self.synced:
            await tree.sync(guild = discord.Object(id=1216791184651849870))
            self.synced = True
        print(f"We have logged in as {self.user}.")
class my_modal(ui.Modal, title="Trial Log"):
    judge = ui.TextInput(
        label="Judge:",
        style=discord.TextStyle.short,
        placeholder="Judge's name",
        default="",
        required=True,
        max_length=200
    )
    prosecutor = ui.TextInput(
        label="Prosecutor:",
        style=discord.TextStyle.short,
        placeholder="Prosecutor's name",
        default="",
        required=True,
        max_length=200
    )
    defendant = ui.TextInput(
        label="Defendant:",
        style=discord.TextStyle.short,
        placeholder="Defendant's name",
        default="",
        required=True,
        max_length=200
    )
    crimes = ui.TextInput(
        label="Crimes:",
        style=discord.TextStyle.short,
        placeholder="List of crimes",
        default="",
        required=True,
        max_length=200
    )```
#
  outcome = ui.TextInput(
        label="Outcome:",
        style=discord.TextStyle.short,
        placeholder="Trial outcome",
        default="",
        required=True,
        max_length=200
    )

async def on_submit(self, interaction: discord.Interaction):
    embed = discord.Embed(
        title=self.title,
        timestamp=datetime.now(),
        color=discord.Color.blue()
    )
    embed.set_author(name=interaction.user, icon_url=interaction.user.avatar)

    # Add fields to the embed
    embed.add_field(name=self.judge.label, value=str(self.judge), inline=False)
    embed.add_field(name=self.prosecutor.label, value=str(self.prosecutor), inline=False)
    embed.add_field(name=self.defendant.label, value=str(self.defendant), inline=False)
    embed.add_field(name=self.crimes.label, value=str(self.crimes), inline=False)
    embed.add_field(name=self.outcome.label, value=str(self.outcome), inline=False)

    await aclient.get_channel(1216821327554678917).send(embed=embed)
    

    await asyncio.sleep(1)
aclient = client()
tree = app_commands.CommandTree(aclient)

@tree.command(guild= discord.Object(id=1216791184651849870), name = "Trial Log", description="Log")
async def modal(interaction: discord.Interaction):
    await interaction.response.send_modal(my_modal())

aclient.run("MyToken")
random perchBOT
#

@sleek cloud

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.