How to store Modal value data using pycord?

44 Views Asked by At

Im trying to store modal value of the fields until i submit that and even i close it, someone can check it and help me??

This is my modal code:

class MyModal3(Modal):
    def __init__(self) -> None:
        super().__init__(title="Comunicado de Ausência") #title of the modal up top
      
        self.add_item(InputText(label="Quantos dias ficará ausente?", placeholder="Digite aqui", style=discord.InputTextStyle.long, min_length=2, max_length=100))
        self.add_item(InputText(label="Digite o motivo:", placeholder="Digite aqui", style=discord.InputTextStyle.long, min_length=10, max_length=100))
        

    async def callback(self, interaction: discord.Interaction):
        embed = discord.Embed(title="Registro de Ausência ️", color=discord.Color.blurple())
        mention = interaction.user.mention
        embed.add_field(name=" | Registrado por:", value=mention, inline=False)
        embed.add_field(name="```️ | Dias ausente:```", value=self.children[0].value, inline=False)
        embed.add_field(name="```| Motivo:```", value=self.children[1].value, inline=False)
        avatar_url = interaction.user.avatar.url  
        embed.set_thumbnail(url=avatar_url)
    
        channel_id = 1161789446262378566  # Substitua pelo ID do canal desejado
        channel = bot.get_channel(channel_id)
        await channel.send(embed=embed)
        await interaction.response.defer()

brasilia = pytz.timezone('America/Sao_Paulo')


@bot.slash_command(guild_ids = servers, name= "ausência", description= "Utilize este comando para abrir registrar os dias que ficará ausente.")
async def ausencia(ctx):
    ausencia = MyModal3()
    await ctx.interaction.response.send_modal(ausencia)
    
0

There are 0 best solutions below