-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚫 Don't allow the main message to be deleted
- Loading branch information
Showing
2 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ClaimBuilder } from "@/class/ClaimBuilder"; | ||
import { Database } from "@/controller/database"; | ||
import Claim from "@/entity/Claim.entry"; | ||
import { AuditLogEvent, EmbedBuilder } from "discord.js"; | ||
import { Event } from "../base"; | ||
const claim = new Database<Claim>({ table: 'Claim' }) | ||
|
||
new Event({ | ||
name: 'messageDelete', | ||
async run(message) { | ||
if (!message.inGuild()) return | ||
const { id } = message | ||
const claimData = await claim.findOne({ where: { messageId: id }, relations: { ticket: true } }) | ||
if (claimData === null || claimData?.ticket?.id === undefined) return | ||
|
||
const builder = await new ClaimBuilder({ interaction: message }).setTicketId(claimData.ticket.id).render() | ||
if (builder === undefined) return | ||
|
||
const nemMessage = await message.channel.send({ | ||
embeds: [builder.embed as EmbedBuilder], | ||
components: builder.buttons | ||
}) | ||
|
||
await claim.save(Object.assign(claimData, { messageId: nemMessage.id })) | ||
|
||
const auditLog = (await message.guild.fetchAuditLogs({ type: AuditLogEvent.MessageDelete })).entries.first() | ||
await message.channel.send({ | ||
content: auditLog?.executor?.id !== undefined ? `<@${auditLog?.executor?.id}>` : undefined, | ||
embeds: [new EmbedBuilder({ | ||
title: '⚠️ Não é possivel deletar a messagem acima!', | ||
footer: { text: 'Essa mensagem será deletada em 5s' } | ||
}).setColor('Red')] | ||
}) | ||
.then(async (msg) => setTimeout(() => { msg.delete() }, 5000)) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters