nyx/command/Information/ping.js

35 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-10-31 02:39:28 +01:00
const { EmbedBuilder } = require("discord.js");
module.exports = {
name: "ping",
description: "Check bot latency to Discord API",
category: "Information",
run: async (client, interaction, args) => {
const msg = await interaction.channel.send(`Pinging...`);
const messageping = msg.createdTimestamp - interaction.createdTimestamp;
await msg.delete();
const Embed = new EmbedBuilder()
.setTitle("<a:pong:897383314405605436> Pong!")
.setAuthor({
name: interaction.user.username,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
})
.setDescription(
`\n 📨 • **Message Latency** \`${Math.floor(messageping)}ms\`
\n🛰 **Bot Latency** \`${Math.round(client.ws.ping)}ms\``
)
.setFooter({
text: `Made by ${client.author}`,
iconURL: client.user.displayAvatarURL({ dynamic: true }),
})
.setTimestamp()
.setColor(
messageping < 350
? "#008000"
: messageping < 500 && messageping > 350
? "#ffff31"
: "#ff0000"
);
interaction.followUp({ embeds: [Embed] });
},
};