from discord.ext import commands
from discord import ui, app_commands
from datetime import datetime
import discord
class Report(commands.Cog, name="Report"):
def __init__(self, bot: commands.Bot):
self.bot = bot
@discord.app_commands.command(name = "report", description = "test modal")
async def Report(self, interaction: discord.Interaction):
class my_modal(ui.Modal, title = "test modal"):
answer = ui.TextInput(label = "test", style = discord.TextStyle.short, placeholder = "test", default = "test2", required = True)
async def on_submit(self, interaction: discord.Interaction):
embed = discord.Embed(title = self.title, description = f"{self.answer.label}, {self.answer}", timestamp = datetime.now(), color = discord.Colour.blue())
embed.set_author(name = interaction.user, icon_url=interaction.user.avatar)
await interaction.response.send_message(embed=embed)
async def setup(client):
await client.add_cog(Report(client), guilds=[discord.Object(id=1341723521906114643)])
#π help! im trying to make a discord modal but im getting no errors!
16 messages Β· Page 1 of 1 (latest)
@agile saddle
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.
Closes after a period of inactivity, or when you send !close.
define modals externally
how π
You never sent the modal to the user
!d discord.InteractionResponse.send_modal
await send_modal(modal, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a modal.
Changed in version 2.5: This now returns a [`InteractionCallbackResponse`](https://discordpy.readthedocs.io/en/stable/interactions/api.html#discord.InteractionCallbackResponse) instance.
send modal isnt defined
it is
make sure you move that modal out of the command definition
This help channel has been closed. 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.