Skip to content

Instantly share code, notes, and snippets.

@net-tech

net-tech/ping.js Secret

Created October 26, 2022 10:25
Show Gist options
  • Save net-tech/1aac0c3321e1ffd1ad31c22de6805a4f to your computer and use it in GitHub Desktop.
Save net-tech/1aac0c3321e1ffd1ad31c22de6805a4f to your computer and use it in GitHub Desktop.
const { Stopwatch } = require("stopwatch")
const prettyMilliseconds = require('pretty-ms');
const { CommandType } = require("wokcommands");
module.exports = {
aliases: ['status'],
name: 'ping',
category: 'Utility',
description: 'Get the websocket latency',
cooldown: '3s',
cooldowns: {
perUser: 3,
},
guildOnly: true,
type: CommandType.BOTH,
ownerOnly: false,
testOnly: false,
callback: async ({ client, message, interaction }) => {
console.log("1")
if (interaction) {
await interaction.reply("📡 Ping 1")
const stopwatch = new Stopwatch().start()
await interaction.editReply("🛰️ Ping 2")
stopwatch.stop()
interaction.editReply(`⏱️ Message Latency: ${stopwatch.toString()}\n🛰️ Websocket Latency: ${client.ws.ping}\n🔌 Uptime: ${await prettyMilliseconds(client.uptime)}`)
} else {
let msg = await message.channel.send("📡 Ping 1")
const stopwatch = new Stopwatch().start()
msg = await msg.edit("🛰️ Ping 2")
stopwatch.stop()
msg.edit(`⏱️ Message Latency: ${stopwatch.toString()}\n🛰️ Websocket Latency: ${client.ws.ping}\n🔌 Uptime: ${await prettyMilliseconds(client.uptime)}`)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment