2022-10-26 12:38:28 +02:00
|
|
|
const { EmbedBuilder } = require("discord.js");
|
2021-09-06 12:38:25 +02:00
|
|
|
const moment = require("moment");
|
|
|
|
module.exports = {
|
|
|
|
name: "snipe",
|
2021-09-21 01:51:56 +02:00
|
|
|
description: "Snipes a deleted message",
|
2021-09-06 12:38:25 +02:00
|
|
|
category: "Utilities",
|
2021-09-21 01:51:56 +02:00
|
|
|
options: [
|
|
|
|
{
|
|
|
|
type: 7,
|
|
|
|
name: "channel",
|
|
|
|
description: "The sniped channel",
|
|
|
|
required: true,
|
2022-10-26 12:38:28 +02:00
|
|
|
channelTypes: [0],
|
2021-09-21 01:51:56 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 4,
|
|
|
|
name: "message",
|
|
|
|
description: "The sniped message",
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
],
|
2021-09-06 12:38:25 +02:00
|
|
|
run: async (client, interaction, args) => {
|
|
|
|
var i = 0;
|
2021-11-18 18:56:42 +01:00
|
|
|
let description = "";
|
2022-10-26 12:38:28 +02:00
|
|
|
const embed = new EmbedBuilder()
|
2021-09-06 12:38:25 +02:00
|
|
|
.setAuthor(
|
|
|
|
`Sniped by ${interaction.user.tag}`,
|
|
|
|
interaction.user.displayAvatarURL({ dynamic: true })
|
|
|
|
)
|
|
|
|
.setColor(client.color)
|
2022-10-26 12:38:28 +02:00
|
|
|
.setFooter({
|
|
|
|
text: `Made by ${client.author}`,
|
|
|
|
iconURL: client.user.displayAvatarURL(),
|
|
|
|
})
|
2021-09-21 01:51:56 +02:00
|
|
|
.setTimestamp()
|
2021-09-06 12:38:25 +02:00
|
|
|
.setURL(client.web);
|
2021-09-21 01:51:56 +02:00
|
|
|
const snipes = client.snipes.get(args[0]) || [];
|
2021-11-18 18:56:42 +01:00
|
|
|
if (interaction.guild.channels.cache.get(args[0]).type !== "GUILD_TEXT") {
|
2021-09-21 01:51:56 +02:00
|
|
|
interaction.followUp({ content: "Please provide a text channel" });
|
2021-11-18 18:56:42 +01:00
|
|
|
} else if (args[1]) {
|
2021-09-21 01:51:56 +02:00
|
|
|
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**Content:** ${m.content}\n${map ? map.join("\n") : ""}`;
|
2021-09-06 12:38:25 +02:00
|
|
|
i++;
|
2021-09-21 01:51:56 +02:00
|
|
|
} else {
|
2021-09-06 12:38:25 +02:00
|
|
|
description += `\n\n**Author:** None (Deleted ${moment(
|
2021-09-21 01:51:56 +02:00
|
|
|
m.date
|
|
|
|
).fromNow()})\n\n**Content:** ${m.content}\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**Content:** ${msg.content}\n${map ? map.join("\n") : ""}`;
|
2021-09-06 12:38:25 +02:00
|
|
|
i++;
|
|
|
|
} else {
|
2021-09-21 01:51:56 +02:00
|
|
|
description += `\n\n**Author:** None (Deleted ${moment(
|
|
|
|
msg.date
|
|
|
|
).fromNow()})\n\n**Content:** ${msg.content}\n${
|
|
|
|
map ? map.join("\n") : ""
|
|
|
|
}`;
|
2021-09-06 12:38:25 +02:00
|
|
|
i++;
|
|
|
|
}
|
2021-09-21 01:51:56 +02:00
|
|
|
embed.setDescription(description);
|
|
|
|
return interaction.followUp({ embeds: [embed] });
|
|
|
|
}
|
2021-11-18 18:56:42 +01:00
|
|
|
} else if (!snipes.length) {
|
|
|
|
interaction.followUp({
|
|
|
|
content: "There isn't any snipe in this channel yet",
|
|
|
|
});
|
2021-09-21 01:51:56 +02:00
|
|
|
} else {
|
2021-11-18 18:56:42 +01:00
|
|
|
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**Content:** ${m.content}\n${map ? map.join("\n") : ""}`;
|
|
|
|
i++;
|
|
|
|
} else {
|
|
|
|
description += `\n\n**Author:** None (Deleted ${moment(
|
|
|
|
m.date
|
|
|
|
).fromNow()})\n\n**Content:** ${m.content}\n${
|
|
|
|
map ? map.join("\n") : ""
|
|
|
|
}`;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
embed.setDescription(description);
|
|
|
|
return interaction.followUp({ embeds: [embed] });
|
2021-09-21 01:51:56 +02:00
|
|
|
}
|
2021-09-06 12:38:25 +02:00
|
|
|
},
|
|
|
|
};
|