Guest User

Untitled

a guest
Dec 6th, 2023
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Command } from '@sapphire/framework';
  2. import { isMessageInstance } from '@sapphire/discord.js-utilities'
  3.  
  4. export class PingCommand extends Command {
  5.     constructor(context, options) {
  6.         super(context, { ...options });
  7.     }
  8.    
  9.     registerApplicationCommands(registry) {
  10.         registry.registerChatInputCommand((builder) =>
  11.             builder
  12.                 .setName('ping')
  13.                 .setDescription('Ping le bot pour vérifier s\'il est en ligne.')
  14.         );
  15.     }
  16.    
  17.     async chatInputRun(interaction) {
  18.         const msg = await interaction.reply({ content: 'Ping ?' , ephemeral: true, fetchReply: true });
  19.        
  20.         if (isMessageInstance(msg)) {
  21.             const diff = msg.createdTimestamp - interaction.createdTimestamp;
  22.             const ping = Math.round(this.container.ws.ping);
  23.             return interaction.editReply(`Pong ! L'allée-retour à pris ${diff}ms. Pouls : ${ping} ms.`)
  24.        }
  25.        
  26.        return interaction.editReply('Impossible de récupérer le ping :(');
  27.    }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment