Untitled

mail@pastecode.io avatar
unknown
python
a month ago
1.9 kB
2
Indexable
Never
# Classe Registrar pedidos
class BotaoPedido(discord.ui.View):
    def __init__(self):
        super().__init__(timeout=None)
    @discord.ui.button(label="Pedido", style=discord.ButtonStyle.blurple, emoji='<:Invite:1255227947133177946>')
    async def on_submit(self, interaction:discord.Interaction, view=View):
        await interaction.response.send_modal(PedidoModal())


class PedidoModal(discord.ui.Modal):
    def __init__(self):
        super().__init__(title='Pedido')

    nome = discord.ui.TextInput(label='Nome', placeholder='Nome do cliente', max_length=10)
    prazo = discord.ui.TextInput(label='Prazo', placeholder='Prazo de entrega', max_length=10)
    descricao = discord.ui.TextInput(label='Descrição', style=discord.TextStyle.long, max_length=5000)

    async def on_submit(self, interaction: discord.Interaction):
        logschannel = interaction.guild.get_channel(id_canal_pedidos)
        embed = discord.Embed(
            color= 26367,
            description= f'**Nome**: {self.nome}\n**Prazo**: {self.prazo}\n**Descrição:** {self.descricao}'
        )
        embedok = discord.Embed(
            colour=26367,
            description='Pedido registrado!'
        )
        await logschannel.send(embed=embed)
        await interaction.response.send_message(embed=embedok, ephemeral=True)


@tree.command(guild=discord.Object(id=1254562365316399195),name="pedido",description='Anotar novo pedido.')
async def _pedido(interaction:discord.Interaction):
    if interaction.permissions.kick_members:
        logschannel = interaction.guild.get_channel(id_canal_pedidos)
        await interaction.response.send_message('Painel Criado', ephemeral=True)
        await interaction.channel.send( view=BotaoPedido())
    else:await interaction.response.send_message(mensagempermissao,ephemeral=True)
Leave a Comment