mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 09:27:24 +00:00
Fix withdraw command
This commit is contained in:
parent
1ef48cc3e7
commit
93a5c5a7b1
2 changed files with 8 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
const Command = require('../../structures/Command');
|
||||
const Util = require('../../util');
|
||||
|
||||
module.exports = class Withdraw extends Command {
|
||||
get name() { return 'withdraw'; }
|
||||
|
@ -10,8 +11,8 @@ module.exports = class Withdraw extends Command {
|
|||
}; }
|
||||
|
||||
async exec(message, { args }) {
|
||||
const amount = args[0];
|
||||
if (isNaN(parseFloat(amount)))
|
||||
const amount = Util.LBRY.ensureDecimal(args[0]);
|
||||
if (!amount)
|
||||
return message.channel.createMessage('The first argument must be a numeric amount of LBC to send!');
|
||||
|
||||
// Check if the balance is more than requested
|
||||
|
|
|
@ -208,5 +208,10 @@ Util.LBRY = {
|
|||
console.info('Created pair', discordID, account.result.id);
|
||||
await client.lbry.fundAccount({ to: account.result.id, amount: config.startingBalance });
|
||||
return account;
|
||||
},
|
||||
ensureDecimal(str) {
|
||||
const num = parseFloat(str);
|
||||
if (isNaN(num)) return null;
|
||||
return Number.isInteger(num) ? `${num}.0` : num.toString();
|
||||
}
|
||||
};
|
Loading…
Add table
Reference in a new issue