feat(example): add /ping command
This commit is contained in:
parent
00ebee7382
commit
e7c377ed0c
1 changed files with 22 additions and 0 deletions
|
@ -145,6 +145,10 @@ client.on("messageCreate", async (message) => {
|
|||
{
|
||||
name: "bassboost",
|
||||
description: "Toggles bassboost filter"
|
||||
},
|
||||
{
|
||||
name: "ping",
|
||||
description: "Shows bot latency"
|
||||
}
|
||||
]);
|
||||
|
||||
|
@ -155,6 +159,24 @@ client.on("messageCreate", async (message) => {
|
|||
client.on("interactionCreate", async (interaction) => {
|
||||
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) {
|
||||
return void interaction.reply({ content: "You are not in a voice channel!", ephemeral: true });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue