From ee3f38f6b60d0e1e7440715a4f3cac45375fdd90 Mon Sep 17 00:00:00 2001 From: Braeden Sowinski Date: Sun, 31 Jul 2022 17:06:12 -0700 Subject: [PATCH] update ping --- commands/ping.js | 12 ++++++++++-- structures/QuarksBot.js | 5 +++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/commands/ping.js b/commands/ping.js index 3bcf4c9..c8efe37 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -18,11 +18,19 @@ module.exports = { * @param {string[]} args * @param {*} param3 */ - run: async (client, interaction, args, { GuildDB }) => { + run: async (client, interaction, args, { GuildDB }, start) => { if (GuildDB.customChannelStatus==true&&!GuildDB.allowedChannels.includes(interaction.channel_id)) { return interaction.send(`You are not allowed to use the bot in this channel.`); } - return interaction.send('Pong!'); + + const end = new Date().getTime(); + const time = end - start; + + const pingEmbed = new MessageEmbed() + .setDescription(`**Pong!** Bot ping: ${time}ms`) + .setColor(client.config.EmbedColor); + + return interaction.send({ embeds: [pingEmbed] }); }, }, } \ No newline at end of file diff --git a/structures/QuarksBot.js b/structures/QuarksBot.js index a26c7cc..7d90451 100644 --- a/structures/QuarksBot.js +++ b/structures/QuarksBot.js @@ -28,6 +28,7 @@ class QuarksBot extends Client { this.Ready = false; this.ws.on("INTERACTION_CREATE", async (interaction) => { + const start = new Date().getTime(); if (interaction.type!=3) { client.log("Interaction") let GuildDB = await this.GetGuild(interaction.guild_id); @@ -53,8 +54,8 @@ class QuarksBot extends Client { }); }; let cmd = client.commands.get(command); - if (cmd.SlashCommand && cmd.SlashCommand.run) - cmd.SlashCommand.run(this, interaction, args, { GuildDB }); + if (cmd.name == 'ping' && cmd.SlashCommand && cmd.SlashCommand.run) cmd.SlashCommand.run(this, interaction, args, { GuildDB }, start); + else if (cmd.SlashCommand && cmd.SlashCommand.run) cmd.SlashCommand.run(this, interaction, args, { GuildDB }); } });