From 1ef48cc3e740e0b21867bdf7c5b5f37d5450359c Mon Sep 17 00:00:00 2001 From: Snazzah Date: Wed, 12 Aug 2020 02:12:36 -0500 Subject: [PATCH] Await response handling --- src/commands/admin/adminbalance.js | 2 +- src/commands/admin/deposit.js | 2 +- src/commands/admin/withdraw.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/admin/adminbalance.js b/src/commands/admin/adminbalance.js index 411edf9..e8dca2c 100644 --- a/src/commands/admin/adminbalance.js +++ b/src/commands/admin/adminbalance.js @@ -10,7 +10,7 @@ module.exports = class AdminBalance extends Command { async exec(message) { const response = await this.client.lbry.walletBalance(); - if (this.handleResponse(message, response)) return; + if (await this.handleResponse(message, response)) return; const wallet = await response.json(); return message.channel.createMessage({ embed: { description: `**Available:** ${wallet.result.available} LBC\n\n` + diff --git a/src/commands/admin/deposit.js b/src/commands/admin/deposit.js index fc43858..0e23adc 100644 --- a/src/commands/admin/deposit.js +++ b/src/commands/admin/deposit.js @@ -10,7 +10,7 @@ module.exports = class Deposit extends Command { async exec(message) { const response = await this.client.lbry.listAddresses(); - if (this.handleResponse(message, response)) return; + if (await this.handleResponse(message, response)) return; const address = await response.json(); return message.channel.createMessage(`Address: ${address.result.items[0].address}`); } diff --git a/src/commands/admin/withdraw.js b/src/commands/admin/withdraw.js index b07dc25..c994139 100644 --- a/src/commands/admin/withdraw.js +++ b/src/commands/admin/withdraw.js @@ -16,7 +16,7 @@ module.exports = class Withdraw extends Command { // Check if the balance is more than requested const balance = await this.client.lbry.walletBalance(); - if (this.handleResponse(message, balance)) return; + if (await this.handleResponse(message, balance)) return; const availableBalance = parseFloat((await balance.json()).result.available); if (parseFloat(amount) > availableBalance) return message.channel.createMessage( @@ -24,7 +24,7 @@ module.exports = class Withdraw extends Command { // Send to wallet const response = await this.client.lbry.sendToWallet({ amount, to: args[1] }); - if (this.handleResponse(message, response)) return; + if (await this.handleResponse(message, response)) return; const txid = (await response.json()).result.inputs[0].txid; return message.channel.createMessage(`Sent ${parseFloat(amount)} LBC to ${args[1]}.\n` + `https://explorer.lbry.com/tx/${txid}`);