Untitled

mail@pastecode.io avatar
unknown
python
a month ago
2.1 kB
3
Indexable
Never
class DeleteTicket(discord.ui.View): #Botão deletar ticket
    def __init__(self):
        super().__init__(timeout=300)
        self.value=None
    @discord.ui.button(label="Encerrar Ticket",style=discord.ButtonStyle.red)
    async def confirm(self,interaction: discord.Interaction, button: discord.ui.Button):
        self.value = True
        self.stop()
        mod = interaction.guild.get_role(id_cargo_atendente)
        if interaction.permissions.manage_guild:
                await interaction.channel.send(f"Criando backup do atendimento...")
                await interaction.response.defer()
                await interaction.followup.send("Seu Atendimento foi encerrado...")
                if os.path.exists(f"{interaction.channel.id}.md"):
                    return await interaction.followup.send(f"Uma transcrição já está sendo gerada!", ephemeral = True)
                with open(f"{interaction.channel.id}.md", 'a',encoding="utf-8") as f:
                    f.write(f"# Transcrição de {interaction.channel.name}:\n\n")
                    async for message in interaction.channel.history(limit = None, oldest_first = True):
                        created = datetime.strftime(message.created_at, "%d/%m/%Y ás %H:%M:%S")
                        if message.edited_at:
                            edited = datetime.strftime(message.edited_at, "%d/%m/%Y ás %H:%M:%S")
                            f.write(f"{message.author} on {created}: {message.clean_content} (Editado em {edited})\n")
                        else:
                            f.write(f"{message.author} on {created}: {message.clean_content}\n")
                    generated = datetime.now().strftime("%d/%m/%Y ás %H:%M:%S")
                    f.write(f"\n*Gerado em {generated}\n*Time Zone: UTC*")
                with open(f"{interaction.channel.id}.md", 'rb') as f:
                    interaction.guild.id == id_servidor
                    canal_logs = interaction.guild.get_channel(id_canal_logs)
                    await interaction.channel.delete()
Leave a Comment