Add a confirmation on withdraw command

This commit is contained in:
Snazzah 2020-08-12 02:51:11 -05:00
parent a0fe4dc5fa
commit 9080fa3b69
No known key found for this signature in database
GPG key ID: 5E71D54F3D86282E
2 changed files with 6 additions and 2 deletions

View file

@ -25,11 +25,15 @@ module.exports = class Withdraw extends Command {
'There is not enough available LBC in the wallet to send that amount!');
// Send to wallet
if (!await this.client.messageAwaiter.confirm(message, {
header: `Are you sure you want to send ${amount} to \`${args[1]}\`? ` +
`*(remaining: ${availableBalance - parseFloat(amount)})*`
})) return;
const response = await this.client.lbry.sendToWallet({ amount, to: args[1] });
const transaction = await response.json();
if (await this.handleResponse(message, response, transaction)) return;
console.debug('withdrew from master wallet', transaction);
return message.channel.createMessage(`Sent ${parseFloat(amount)} LBC to ${args[1]}.\n` +
return message.channel.createMessage(`Sent ${amount} LBC to ${args[1]}.\n` +
`https://explorer.lbry.com/tx/${transaction.result.txid}`);
}

View file

@ -88,7 +88,7 @@ class Command {
{ message: 'Internal server error' } : json.error;
console.error(`SDK error in ${this.name}:${message.author.id}`, response, error);
await message.channel.createMessage(
`LBRY-SDK returned ${response.status} witn an error: \`${error.message}\``);
`LBRY-SDK returned ${response.status} with an error: \`${error.message}\``);
return true;
}
return false;