0

The embed goes to the right channel, the confirmation message works, and nothing shows up on console... but the modal has a error of "Something went wrong. Please try again" when pressing submit.

import disnake
from disnake.ext import commands
from disnake import TextInputStyle

class FactionModal(disnake.ui.Modal):
  def __init__(self):
    components = [disnake.ui.TextInput(label="Faction Name", custom_id="name", placeholder="Clan", style=TextInputStyle.short), disnake.ui.TextInput(label="Members", custom_id="Members", placeholder="1. CraftyTheHawk", style=TextInputStyle.paragraph)]

    super().__init__(title="Faction Application", custom_id="faction", components=components)

  async def callback(self, inter: disnake.ModalInteraction):
    channel = disnake.utils.get(inter.guild.text_channels, id=1036359251926466591)
    embed = disnake.Embed(title="Faction Application")
    for key, value in inter.text_values.items():
      embed.add_field(name=key.capitalize(),value=value[:1024],inline=False)
    await channel.send(embed=embed)

class faction_cog(commands.Cog):
  def __init__(self, bot):
    self.bot = bot

  @commands.slash_command(name='faction', description='Apply to get your faction official!')
  async def faction(inter: disnake.AppCmdInter):
    await inter.response.send_modal(modal=FactionModal())
    await inter.channel.send(f"Faction Application Successfully Submitted by {inter.user}")

def setup(bot):
  bot.add_cog(faction_cog(bot))```

1 Answers1

0

You need to respond to the interaction using inter.response. Sending a message in the channel using any other method than this doesn't count unless you deferred the interaction; the interaction will fail after 3 seconds if you don't respond to it.

async def callback(self, inter: disnake.ModalInteraction):
    ...

    await inter.response.send(content="Success!")

You can look at the official example here.

Catgal
  • 644
  • 1
  • 3
  • 8