nyx/command/Information/messageinfo.js

42 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-09-06 12:38:25 +02:00
const { MessageEmbed } = require("discord.js");
module.exports = {
name: "messageinfo",
category: "Information",
type: "CHAT_INPUT",
description: "Check the info of a message",
options: [
{
type: 3,
name: "message",
description: "The message you want to see",
required: true,
},
],
run: async (client, interaction, args) => {
try {
await interaction.channel.messages.fetch(args[0]).catch(async err => {
return await interaction.followUp({
content: "Message not found in this channel..",
});
});
const msg = await interaction.channel.messages.cache.get(args[0]);
const hasImage = msg.attachments.size && msg.attachments.first().width;
const embed = new MessageEmbed()
.setColor(msg.member ? msg.member.displayHexColor : client.color)
.setImage(hasImage ? msg.attachments.first().url : null)
.setAuthor(
msg.author.tag,
msg.author.displayAvatarURL({ format: "png", dynamic: true })
)
.addField("Content", msg.content || "No content")
.setTimestamp(msg.createdAt)
.addField("ID", msg.id)
.setFooter(`Made by ${client.author}`)
.addField("Jump", `[Click Here to Jump](${msg.url})`);
return await interaction.followUp({ embeds: [embed] });
} catch (err) {
console.log(err);
}
},
};