ping.js (1196B)
1 const { EmbedBuilder } = require("discord.js"); 2 module.exports = { 3 name: "ping", 4 description: "Check bot latency to Discord API", 5 category: "Information", 6 run: async (client, interaction, args) => { 7 const msg = await interaction.channel.send(`Pinging...`); 8 const messageping = msg.createdTimestamp - interaction.createdTimestamp; 9 await msg.delete(); 10 const Embed = new EmbedBuilder() 11 .setTitle("<a:pong:897383314405605436> Pong!") 12 .setAuthor({ 13 name: interaction.user.username, 14 iconURL: interaction.user.displayAvatarURL({ dynamic: true }), 15 }) 16 .setDescription( 17 `\n 📨 • **Message Latency** \`${Math.floor(messageping)}ms\` 18 \n🛰️ • **Bot Latency** \`${Math.round(client.ws.ping)}ms\`` 19 ) 20 .setFooter({ 21 text: `Made by ${client.author}`, 22 iconURL: client.user.displayAvatarURL({ dynamic: true }), 23 }) 24 .setTimestamp() 25 .setColor( 26 messageping < 350 27 ? "#008000" 28 : messageping < 500 && messageping > 350 29 ? "#ffff31" 30 : "#ff0000" 31 ); 32 interaction.followUp({ embeds: [Embed] }); 33 }, 34 };