nyx/command/Information/ping.js

35 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2022-10-26 12:38:28 +02:00
const { EmbedBuilder } = require("discord.js");
2021-09-06 12:38:25 +02:00
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();
2022-10-26 12:38:28 +02:00
const Embed = new EmbedBuilder()
.setTitle("<a:pong:897383314405605436> Pong!")
2022-10-26 12:38:28 +02:00
.setAuthor({
2023-02-03 20:14:39 +01:00
name: interaction.user.username,
2023-04-02 14:12:53 +02:00
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
2022-10-26 12:38:28 +02:00
})
2021-09-06 12:38:25 +02:00
.setDescription(
`\n 📨 • **Message Latency** \`${Math.floor(messageping)}ms\`
\n🛰 **Bot Latency** \`${Math.round(client.ws.ping)}ms\``
2021-09-06 12:38:25 +02:00
)
2022-10-26 12:38:28 +02:00
.setFooter({
text: `Made by ${client.author}`,
2023-04-02 14:12:53 +02:00
iconURL: client.user.displayAvatarURL({ dynamic: true }),
2022-10-26 12:38:28 +02:00
})
.setTimestamp()
2021-09-06 12:38:25 +02:00
.setColor(
messageping < 350
2022-10-26 12:38:28 +02:00
? "#008000"
2021-09-06 12:38:25 +02:00
: messageping < 500 && messageping > 350
2022-10-26 12:38:28 +02:00
? "#ffff31"
: "#ff0000"
2021-09-06 12:38:25 +02:00
);
interaction.followUp({ embeds: [Embed] });
2021-09-06 12:38:25 +02:00
},
};