mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +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 Command = require('../../structures/Command');
|
||||||
|
const Util = require('../../util');
|
||||||
|
|
||||||
module.exports = class Withdraw extends Command {
|
module.exports = class Withdraw extends Command {
|
||||||
get name() { return 'withdraw'; }
|
get name() { return 'withdraw'; }
|
||||||
|
@ -10,8 +11,8 @@ module.exports = class Withdraw extends Command {
|
||||||
}; }
|
}; }
|
||||||
|
|
||||||
async exec(message, { args }) {
|
async exec(message, { args }) {
|
||||||
const amount = args[0];
|
const amount = Util.LBRY.ensureDecimal(args[0]);
|
||||||
if (isNaN(parseFloat(amount)))
|
if (!amount)
|
||||||
return message.channel.createMessage('The first argument must be a numeric amount of LBC to send!');
|
return message.channel.createMessage('The first argument must be a numeric amount of LBC to send!');
|
||||||
|
|
||||||
// Check if the balance is more than requested
|
// Check if the balance is more than requested
|
||||||
|
|
|
@ -208,5 +208,10 @@ Util.LBRY = {
|
||||||
console.info('Created pair', discordID, account.result.id);
|
console.info('Created pair', discordID, account.result.id);
|
||||||
await client.lbry.fundAccount({ to: account.result.id, amount: config.startingBalance });
|
await client.lbry.fundAccount({ to: account.result.id, amount: config.startingBalance });
|
||||||
return account;
|
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