Allow admins to see others balances

This commit is contained in:
Snazzah 2020-09-19 04:39:03 -05:00
parent 0ba37c0920
commit 8ecec7e455
No known key found for this signature in database
GPG key ID: 5E71D54F3D86282E

View file

@ -10,7 +10,33 @@ module.exports = class Balance extends Command {
permissions: ['curatorOrAdmin']
}; }
async exec(message) {
async exec(message, { args }) {
if (args.length) {
if (!Util.CommandPermissions.admin(this.client, message)) {
const admins = (Array.isArray(config.adminRoleID) ? config.adminRoleID : [config.adminRoleID])
.map(id => `"${this.client.guilds.get(config.guildID).roles.get(id).name}"`);
return message.channel.createMessage(
`You need to have the ${admins.join('/')} role(s) to see others balances!`);
}
const discordID = Util.resolveToUserID(args[0]);
if (!discordID)
return message.channel.createMessage('That Discord user isn\'t valid.');
const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false);
if (!account.accountID)
return message.channel.createMessage('That Discord user does not have an account.');
const response = await this.client.lbry.accountBalance(account.accountID);
const wallet = await response.json();
if (await this.handleResponse(message, response, wallet)) return;
return message.channel.createMessage({ embed: {
color: config.embedColor,
description: `<@${discordID}> has **${wallet.result.available}** LBC available.\n\n` +
`Reserved in Supports: ${wallet.result.reserved_subtotals.supports} LBC\n` +
`Total: ${wallet.result.total} LBC`
} });
} else {
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
const response = await this.client.lbry.accountBalance(account.accountID);
const wallet = await response.json();
@ -24,6 +50,7 @@ module.exports = class Balance extends Command {
'Please wait a few seconds, and run the command again to get an accurate balance.' : '')
} });
}
}
get metadata() { return {
category: 'Curator',