Discord.py modal form command has no response despite no errors in console

I want to make a command such that when I use it, a form would pop up for me to complete and my responses will be DMed to me and posted in another channel afterwards. Below is the code I used (I referred to multiple YouTube tutorials) in a group cog named modal; the names and numbers are altered slightly due to privacy and stuff.

I am able to run the bot normally without any errors, and all my other cogs and commands work as normal. However, when I use the modal form command, the bot does not respond at all, despite there bring no errors printed in the console.

The numbers 2, 3, 4, 5, 6, 7 and 8 are printed in the console when starting up the bot (why does this happen???), and when I used the modal form command, only number 0 is printed in the console, which might mean that await interaction.response.send_modal(myModal()) is not working for some reason.


What I expected to happen

  • When I use the command, console prints 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 15 15 15 15 16 17 18 19 20
  • Discord shows me a modal form with 5 questions to complete (all required, paragraph, 1000-character limit), and an embed containing my responses is sent to a text channel and my DMs after I complete the modal form
  • The bot responds to the command with a message containing my username and user ID after I complete the modal form

What actually happened

  • When I start up the bot, console prints 2 3 4 5 6 7 8 (why???)
  • When I use the command, console prints 0 (why???)
  • The bot does not respond to the command (shows “The application did not respond” after a few seconds)

File: commands/slash_commands_modal.py

import discord
from discord import app_commands, ui
from discord.ext import commands
from misc.dicts import DICT

class myModal(ui.Modal, title="Why not working"):
   print("2") # debug no.2
   a1 = ui.TextInput(
      label=DICT["a"][0],
      placeholder=DICT["ax"][0],
      style=discord.TextStyle.paragraph,
      max_length=1000,
      required=True
      )
   print("3") # debug no.3
   a2 = ui.TextInput(
      label=DICT["a"][1],
      placeholder=DICT["ax"][1],
      style=discord.TextStyle.paragraph,
      max_length=1000,
      required=True
      )
   print("4") # debug no.4
   a3 = ui.TextInput(
      label=DICT["a"][2],
      placeholder=DICT["ax"][2],
      style=discord.TextStyle.paragraph,
      max_length=1000,
      required=True
      )
   print("5") # debug no.5
   a4 = ui.TextInput(
      label=DICT["a"][3],
      placeholder=DICT["ax"][3],
      style=discord.TextStyle.paragraph,
      max_length=1000,
      required=True
      )
   print("6") # debug no.6
   a5 = ui.TextInput(
      label=DICT["a"][4],
      placeholder=DICT["ax"][4],
      style=discord.TextStyle.paragraph,
      max_length=1000,
      required=True
      )
   print("7") # debug no.7
   a = [a1,a2,a3,a4,a5]
   print("8") # debug no.8
   async def on_submit(self, interaction: discord.Interaction):
      print("9") # debug no.9
      channel = self.bot.get_channel(9999999999999999999)
      print("10") # debug no.10
      d = f"- Username: **{interaction.user.name}**n- User ID: ||**`{interaction.user.id}`**||"
      print("11") # debug no.11
      e = discord.Embed(title=f"Form", description=d, colour=0xe74c3c)
      print("12") # debug no.12
      e.set_footer(text="Form Response")
      print("13") # debug no.13
      q = DICT["a"]
      print("14") # debug no.14
      for i, j in zip(q, self.a):
         e.add_field(name=i, value=j, inline=False)
         print("15") # debug no.15
      await channel.send(embed=e)
      print("16") # debug no.16
      await interaction.response.send_message(f"- Username: **{interaction.user.name}**n- User ID: ||**`{interaction.user.id}`**||nnThe form is done yay", ephemeral=True)
      print("17") # debug no.17
      user = self.bot.get_user(interaction.user.id)
      print("18") # debug no.18
      await user.create_dm()
      print("19") # debug no.19
      await user.dm_channel.send(embed=e)
      print("20") # debug no.20

class SlashCmd_Modal(commands.GroupCog, group_name="modal"):
  def __init__(self, bot):
      self.bot = bot

  @app_commands.command(name="form", description="a description")
  @app_commands.describe(role="another description")
  @app_commands.choices(role = [
    app_commands.Choice(name="A", value="a"),
    app_commands.Choice(name="B", value="b"),
    app_commands.Choice(name="C", value="c"),
    app_commands.Choice(name="D", value="d")
  ])
  async def form(self, interaction: discord.Interaction, role: str):
    if role == "a":
       print("0") # debug no.0
       await interaction.response.send_modal(myModal())
       print("1") # debug no.1
    elif role == "b":
       ... # similar kind of form but different class
    elif role == "c":
       ... # similar kind of form but different class
    elif role == "d":
       ... # similar kind of form but different class

async def setup(bot):
  await bot.add_cog(SlashCmd_Modal(bot))

File: misc/dict.py

DICT = {
"a": [ # questions
    "Q1",
    "Q2",
    "Q3",
    "Q4",
    "Q5"
],
"ax": [ # placeholders
    "P1",
    "P2",
    "P3",
    "P4",
    "P5"
]
}

New contributor

AJ Goh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật