|
|
|
|
@ -1,10 +1,8 @@
|
|
|
|
|
import confirmationMessage from '../../utils/confirmationMessage.js';
|
|
|
|
|
import EmojiEmbed from '../../utils/generateEmojiEmbed.js';
|
|
|
|
|
import { LoadingEmbed } from '../../utils/defaults.js';
|
|
|
|
|
import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, GuildTextBasedChannel, Message, MessageContextMenuCommandInteraction } from "discord.js";
|
|
|
|
|
import Discord, { ActionRowBuilder, ButtonBuilder, ButtonStyle, ContextMenuCommandBuilder, GuildMember, GuildTextBasedChannel, Message, MessageContextMenuCommandInteraction } from "discord.js";
|
|
|
|
|
import client from "../../utils/client.js";
|
|
|
|
|
import getEmojiByName from '../../utils/getEmojiByName.js';
|
|
|
|
|
import { JSONTranscriptFromMessageArray, JSONTranscriptToHumanReadable } from "../../utils/logTranscripts.js";
|
|
|
|
|
import { messageException } from '../../utils/createTemporaryStorage.js';
|
|
|
|
|
|
|
|
|
|
const command = new ContextMenuCommandBuilder()
|
|
|
|
|
@ -187,13 +185,16 @@ const callback = async (interaction: MessageContextMenuCommandInteraction) => {
|
|
|
|
|
log(data);
|
|
|
|
|
const messages: Message[] = deleted.map(m => m).filter(m => m instanceof Message).map(m => m as Message);
|
|
|
|
|
if (messages.length === 1) messageException(interaction.guild!.id, interaction.channel.id, messages[0]!.id)
|
|
|
|
|
const transcript = JSONTranscriptToHumanReadable(JSONTranscriptFromMessageArray(messages)!);
|
|
|
|
|
const attachmentObject = {
|
|
|
|
|
attachment: Buffer.from(transcript),
|
|
|
|
|
name: `purge-${channel.id}-${Date.now()}.txt`,
|
|
|
|
|
description: "Purge log"
|
|
|
|
|
};
|
|
|
|
|
const m = (await interaction.editReply({
|
|
|
|
|
const messageArray: Message[] = messages.filter(message => !(
|
|
|
|
|
message!.components.some(
|
|
|
|
|
component => component.components.some(
|
|
|
|
|
child => child.customId?.includes("transcript") ?? false
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
)).map(message => message as Message);
|
|
|
|
|
const transcript = await client.database.transcripts.createTranscript(messageArray, interaction, interaction.member as GuildMember);
|
|
|
|
|
const code = await client.database.transcripts.create(transcript);
|
|
|
|
|
await interaction.editReply({
|
|
|
|
|
embeds: [
|
|
|
|
|
new EmojiEmbed()
|
|
|
|
|
.setEmoji("CHANNEL.PURGE.GREEN")
|
|
|
|
|
@ -203,47 +204,10 @@ const callback = async (interaction: MessageContextMenuCommandInteraction) => {
|
|
|
|
|
],
|
|
|
|
|
components: [
|
|
|
|
|
new Discord.ActionRowBuilder<ButtonBuilder>().addComponents([
|
|
|
|
|
new Discord.ButtonBuilder()
|
|
|
|
|
.setCustomId("download")
|
|
|
|
|
.setLabel("Download transcript")
|
|
|
|
|
.setStyle(ButtonStyle.Success)
|
|
|
|
|
.setEmoji(getEmojiByName("CONTROL.DOWNLOAD", "id"))
|
|
|
|
|
new ButtonBuilder().setLabel("View").setStyle(ButtonStyle.Link).setURL(`https://clicks.codes/nucleus/transcript?code=${code}`),
|
|
|
|
|
])
|
|
|
|
|
]
|
|
|
|
|
})) as Discord.Message;
|
|
|
|
|
let component;
|
|
|
|
|
try {
|
|
|
|
|
component = await m.awaitMessageComponent({
|
|
|
|
|
filter: (i) => i.user.id === interaction.user.id && i.channel!.id === interaction.channel!.id && i.id === m.id,
|
|
|
|
|
time: 300000
|
|
|
|
|
});
|
|
|
|
|
} catch {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (component.customId === "download") {
|
|
|
|
|
interaction.editReply({
|
|
|
|
|
embeds: [
|
|
|
|
|
new EmojiEmbed()
|
|
|
|
|
.setEmoji("CHANNEL.PURGE.GREEN")
|
|
|
|
|
.setTitle("Purge")
|
|
|
|
|
.setDescription("Transcript uploaded above")
|
|
|
|
|
.setStatus("Success")
|
|
|
|
|
],
|
|
|
|
|
components: [],
|
|
|
|
|
files: [attachmentObject]
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
interaction.editReply({
|
|
|
|
|
embeds: [
|
|
|
|
|
new EmojiEmbed()
|
|
|
|
|
.setEmoji("CHANNEL.PURGE.GREEN")
|
|
|
|
|
.setTitle("Purge")
|
|
|
|
|
.setDescription("Messages cleared")
|
|
|
|
|
.setStatus("Success")
|
|
|
|
|
],
|
|
|
|
|
components: []
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const check = async (_interaction: MessageContextMenuCommandInteraction) => {
|
|
|
|
|
|