Await response handling

This commit is contained in:
Snazzah 2020-08-12 02:12:36 -05:00
parent c7f7abe49f
commit 1ef48cc3e7
No known key found for this signature in database
GPG key ID: 5E71D54F3D86282E
3 changed files with 4 additions and 4 deletions

View file

@ -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` +

View file

@ -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}`);
}

View file

@ -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}`);