ping command

This commit is contained in:
kdh8219 2023-04-26 21:49:41 +09:00
parent 90b4da470d
commit 612a9a1668
2 changed files with 22 additions and 15 deletions

View file

@ -1,15 +0,0 @@
const { SlashCommandBuilder, Client, GatewayIntentBits } = require("discord.js");
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.login(process.env.DISCORD_TOKEN);
module.exports = {
data: new SlashCommandBuilder().setName("ping").setDescription("check ping").setDMPermission(false),
async execute(interaction) {
const defer = await interaction.reply({ content: "Pinging...", fetchReply: true, ephemeral: true });
interaction.editReply({
content: `**PONG🏓**\n\`\`\`\n${/*Websocket heartbeat: ${client.ws.ping}ms.*/ ""}\nRoundtrip latency: ${defer.createdTimestamp - interaction.createdTimestamp}ms\nRunner: ${
process.env.RUNNER_NAME
}\n\`\`\``,
});
},
};

22
src/command/commands/ping.ts Executable file
View file

@ -0,0 +1,22 @@
import { SlashCommandBuilder, ChatInputCommandInteraction } from "discord.js";
export default {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("check ping")
.setDMPermission(false),
async execute(interaction: ChatInputCommandInteraction) {
const defer = await interaction.reply({
content: "Pinging...",
fetchReply: true,
ephemeral: true,
});
interaction.editReply({
content: `**PONG🏓**\n\`\`\`\n
Websocket heartbeat: ${interaction.client.ws.ping}ms.
\nRoundtrip latency: ${
defer.createdTimestamp - interaction.createdTimestamp
}ms\nRunner: ${process.env.RUNNER_NAME}\n\`\`\``,
});
},
};