From 4f5812c2b8b663d68097fb7586716a820280619e Mon Sep 17 00:00:00 2001 From: GooeyTuxedo Date: Tue, 18 Apr 2023 21:30:23 -0700 Subject: [PATCH] set status every block, discord doesn't rate limit until 50 req/sec --- src/blockchain.ts | 10 +++++----- src/handlers.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blockchain.ts b/src/blockchain.ts index a6f7871..9f3e884 100644 --- a/src/blockchain.ts +++ b/src/blockchain.ts @@ -20,19 +20,19 @@ export const subToBlockHeaders = (setDiscordStatus: () => Promise) => { web3.eth.subscribe('newBlockHeaders', (error, blockHeader) => { if (error) console.error(error); - // Set status every 10 blocks - const shouldSetStatus = blockHeader.number % 10 === 0; + const shouldLogWei = blockHeader.number % 10 === 0; // Get the gas price for this block web3.eth.getGasPrice((error, gasPrice) => { if (error) console.error(error); - if (shouldSetStatus) console.log('Gas price in wei:', gasPrice); + if (shouldLogWei) console.log('Gas price in wei:', gasPrice); redisClient.set('gas-price', Math.round(Number(gasPrice))) }); - - if (shouldSetStatus) setDiscordStatus() + + // Set status every block + setDiscordStatus() }); } diff --git a/src/handlers.ts b/src/handlers.ts index d4ef482..5ce1aef 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -13,7 +13,7 @@ const handleGasCommand = async (interaction: ChatInputCommandInteraction): Promi const embed = new EmbedBuilder() .setColor('#0099ff') .setTitle('Current Gas Prices') - .setDescription(`⚡${gasPrices.fast} ⦚⦚ 🚶${gasPrices.average} ⦚⦚ 🐢${gasPrices.slow}`) + .setDescription(`⚡ ${gasPrices.fast} ⦚⦚ 🚶 ${gasPrices.average} ⦚⦚ 🐢 ${gasPrices.slow}`) await interaction.reply({ embeds: [embed] }); };