Files
Femboy-Croissant-Bot/commands/utility/ping.js
2026-03-15 11:58:43 +01:00

33 lines
1.2 KiB
JavaScript

const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = {
category: 'utility',
data: new SlashCommandBuilder()
.setName('ping')
.setDescription('Affiche la latence du bot.'),
async execute(interaction) {
const sent = await interaction.deferReply({ fetchReply: true });
const apiLatency = Math.round(interaction.client.ws.ping);
const roundTripLatency = sent.createdTimestamp - interaction.createdTimestamp;
const { colors, emojis } = require('../../utils/constants');
const embed = new EmbedBuilder()
.setAuthor({
name: `${interaction.client.user.username}`,
iconURL: interaction.client.user.displayAvatarURL()
})
.setTitle(`${emojis.ping} Statut de la Latence`)
.setColor(colors.utility)
.addFields(
{ name: '🌐 Latence API', value: `\`${apiLatency}ms\``, inline: true },
{ name: '⏱️ Latence Round-Trip', value: `\`${roundTripLatency}ms\``, inline: true }
)
.setFooter({ text: `${interaction.guild.name}${interaction.client.user.username}`, iconURL: interaction.client.user.displayAvatarURL() })
.setTimestamp();
await interaction.editReply({ embeds: [embed] });
},
};