diff --git a/src/modules/general.js b/src/modules/general.js index 99a0080..23feced 100644 --- a/src/modules/general.js +++ b/src/modules/general.js @@ -122,8 +122,8 @@ ping.description = "Measures response times to Discord."; ping.addAlias("p"); ping.callback = async function (msg) { const nonceTimestamp = msg.nonce && snowflakeToTimestamp(msg.nonce); - const now = snowflakeToTimestamp(msg.id); - const noncePing = Math.floor(now - nonceTimestamp); + const msgTimestamp = snowflakeToTimestamp(msg.id); + const noncePing = Math.floor(msgTimestamp - nonceTimestamp); const gateway = hf.bot.shards.get( hf.bot.guildShardMap[hf.bot.channelGuildMap[msg.channel.id]] || 0 @@ -133,6 +133,7 @@ ping.callback = async function (msg) { content: `Pong.\n**RTT:** \`...\`\n**Gateway:** \`${gateway}ms\`${ nonceTimestamp ? `\n**Your Message:** \`${noncePing}ms\`` : "" }`, + nonce: Date.now(), allowedMentions: { repliedUser: false, }, @@ -140,11 +141,9 @@ ping.callback = async function (msg) { messageID: msg.id, }, }); - const rtt = Math.floor( - newMsg.timestamp - (msg.editedTimestamp || msg.timestamp) - ); + const rtt = Math.floor(newMsg.timestamp - newMsg.nonce); - newMsg.edit({ + await newMsg.edit({ content: `Pong.\n**RTT:** \`${rtt}ms\`\n**Gateway:** \`${gateway}ms\`${ nonceTimestamp ? `\n**Your Message:** \`${noncePing}ms\`` : "" }`,