feat(example): add /ping command

This commit is contained in:
DevAndromeda 2021-08-09 19:56:23 +05:45
parent 00ebee7382
commit e7c377ed0c
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -145,6 +145,10 @@ client.on("messageCreate", async (message) => {
{ {
name: "bassboost", name: "bassboost",
description: "Toggles bassboost filter" description: "Toggles bassboost filter"
},
{
name: "ping",
description: "Shows bot latency"
} }
]); ]);
@ -155,6 +159,24 @@ client.on("messageCreate", async (message) => {
client.on("interactionCreate", async (interaction) => { client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand() || !interaction.guildId) return; if (!interaction.isCommand() || !interaction.guildId) return;
if (interaction.commandName === "ping") {
await interaction.deferReply();
const queue = player.getQueue(interaction.guild);
return void interaction.followUp({
embeds: [
{
title: "⏱️ | Latency",
fields: [
{ name: "Bot Latency", value: `\`${Math.round(client.ws.ping)}ms\`` },
{ name: "Voice Latency", value: !queue ? "N/A" : `UDP: \`${queue.connection.voiceConnection.ping.udp ?? "N/A"}\`ms\nWebSocket: \`${queue.connection.voiceConnection.ping.ws ?? "N/A"}\`ms` }
],
color: 0xFFFFFF
}
]
});
}
if (!(interaction.member instanceof GuildMember) || !interaction.member.voice.channel) { if (!(interaction.member instanceof GuildMember) || !interaction.member.voice.channel) {
return void interaction.reply({ content: "You are not in a voice channel!", ephemeral: true }); return void interaction.reply({ content: "You are not in a voice channel!", ephemeral: true });
} }