nyx/command/Information/messageinfo.js
2021-09-06 18:38:25 +08:00

41 lines
1.4 KiB
JavaScript

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);
}
},
};