mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +00:00
Await response handling
This commit is contained in:
parent
c7f7abe49f
commit
1ef48cc3e7
3 changed files with 4 additions and 4 deletions
|
@ -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` +
|
||||
|
|
|
@ -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}`);
|
||||
}
|
||||
|
|
|
@ -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}`);
|
||||
|
|
Loading…
Add table
Reference in a new issue