Untitled

mail@pastecode.io avatar
unknown
python
15 days ago
1.6 kB
2
Indexable
Never
class DeleteButton(discord.ui.Button):
    def __init__(self, label, style, user):
        super().__init__(label=label, style=style)
        self.user = user

    async def callback(self, interaction: discord.Interaction):
        if any(role.id == id_suporte for role in interaction.user.roles):

            messages = []
            async for message in interaction.channel.history(limit=None):
                messages.append(message)

            log_content = "\n".join([f"{msg.author.name}: {msg.content}" for msg in messages])
            log = pysourcebin.create(name='FactoryBots',title='Johny Logs', description='logs ticket', code=log_content)

            embed = discord.Embed(
                description=f"**Aberto por:** {self.user.mention}\n\n**Finalizado por:** {interaction.user.mention}",
                color= 26367
            )
            embed.set_author(name='FactoryBots | Sistema de logs')

            embed2 = discord.Embed(
                description=f"Ticket finalizado.\nGostariamos de ouvir sua opinião sobre o nosso atendimento <#1254570720521097257>.",
                colour= 26367
            )
            logs = discord.ui.Button(label='Logs', url=log)
            await interaction.guild.get_channel(id_logs_ticket).send(embed=embed, view=discord.ui.View().add_item(logs))
            await interaction.channel.delete()
            await self.user.send(embed=embed2)
        else:
            await interaction.response.send_message("Você não tem permissão.", ephemeral=True)
Leave a Comment