diff --git a/src/commands/admin/withdraw.js b/src/commands/admin/withdraw.js index c994139..a5d02fc 100644 --- a/src/commands/admin/withdraw.js +++ b/src/commands/admin/withdraw.js @@ -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 diff --git a/src/util.js b/src/util.js index a115149..4bd1348 100644 --- a/src/util.js +++ b/src/util.js @@ -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(); } }; \ No newline at end of file