nyx/unused/commands/Utilities/esnipe.js
2022-10-26 10:38:28 +00:00

131 lines
4.3 KiB
JavaScript

const { EmbedBuilder } = require("discord.js");
const moment = require("moment");
module.exports = {
name: "editsnipe",
description: "Snipes a edited message",
category: "Utilities",
options: [
{
type: 7,
name: "channel",
description: "The sniped channel",
required: true,
channelTypes: [0],
},
{
type: 4,
name: "message",
description: "The sniped message",
required: false,
},
],
run: async (client, interaction, args) => {
var i = 0;
let description = "";
const embed = new EmbedBuilder()
.setAuthor(
`Sniped by ${interaction.user.tag}`,
interaction.user.displayAvatarURL({ dynamic: true })
)
.setColor(client.color)
.setFooter({
text: `Made by ${client.author}`,
iconURL: client.user.displayAvatarURL(),
})
.setTimestamp()
.setURL(client.web);
const snipes = client.esnipes.get(args[0]) || [];
if (interaction.guild.channels.cache.get(args[0]).type !== "GUILD_TEXT") {
interaction.followUp({ content: "Please provide a text channel" });
} else if (args[1]) {
const msg = snipes[args[1] - 1];
if (!msg) {
snipes.forEach(m => {
const map = [];
for (var i = 0; i < m.attachment?.length; i++) {
map.push(
`**Attchment ${i + 1}:** [Click to view](${m.attachment[i]})`
);
}
if (m.author !== "No Author") {
description += `\n\n**Author:** ${m.author.username}#${
m.author.discriminator
} (Deleted ${moment(m.date).fromNow()})\n**ID:** ${
m.author.id
}\n**Old Content:** ${m.oldContent}\n**New Content:** ${
m.newContent
}\n${map ? map.join("\n") : ""}`;
i++;
} else {
description += `\n\n**Author:** None (Deleted ${moment(
m.date
).fromNow()})\n\n**Old Content:** ${
m.oldContent
}\n**New Content:** ${m.newContent}\n${map ? map.join("\n") : ""}`;
i++;
}
});
embed.setDescription(description);
return interaction.followUp({ embeds: [embed] });
} else {
const map = [];
for (var i = 0; i < msg.attachment?.length; i++) {
map.push(
`**Attchment ${i + 1}:** [Click to view](${msg.attachment[i]})`
);
}
if (msg.author !== "No Author") {
description += `\n\n**Author:** ${msg.author.username}#${
msg.author.discriminator
} (Deleted ${moment(msg.date).fromNow()})\n**ID:** ${
msg.author.id
}\n**Old Content:** ${m.oldContent}\n**New Content:** ${
m.newContent
}\n${map ? map.join("\n") : ""}`;
i++;
} else {
description += `\n\n**Author:** None (Deleted ${moment(
msg.date
).fromNow()})\n\n**Old Content:** ${m.oldContent}\n**New Content:** ${
m.newContent
}\n${map ? map.join("\n") : ""}`;
i++;
}
embed.setDescription(description);
return interaction.followUp({ embeds: [embed] });
}
} else if (!snipes.length) {
interaction.followUp({
content: "There isn't any snipe in this channel yet",
});
} else {
snipes.forEach(m => {
const map = [];
for (var i = 0; i < m.attachment?.length; i++) {
map.push(
`**Attchment ${i + 1}:** [Click to view](${m.attachment[i]})`
);
}
if (m.author !== "No Author") {
description += `\n\n**Author:** ${m.author.username}#${
m.author.discriminator
} (Deleted ${moment(m.date).fromNow()})\n**ID:** ${
m.author.id
}\n**Old Content:** ${m.oldContent}\n**New Content:** ${
m.newContent
}\n${map ? map.join("\n") : ""}`;
i++;
} else {
description += `\n\n**Author:** None (Deleted ${moment(
m.date
).fromNow()})\n\n**Old Content:** ${m.oldContent}\n**New Content:** ${
m.newContent
}\n${map ? map.join("\n") : ""}`;
i++;
}
});
embed.setDescription(description);
return interaction.followUp({ embeds: [embed] });
}
},
};