mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +00:00
Allow admins to see others balances
This commit is contained in:
parent
0ba37c0920
commit
8ecec7e455
1 changed files with 40 additions and 13 deletions
|
@ -10,19 +10,46 @@ module.exports = class Balance extends Command {
|
|||
permissions: ['curatorOrAdmin']
|
||||
}; }
|
||||
|
||||
async exec(message) {
|
||||
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();
|
||||
if (await this.handleResponse(message, response, wallet)) return;
|
||||
return message.channel.createMessage({ embed: {
|
||||
color: config.embedColor,
|
||||
description: `You have **${wallet.result.available}** LBC available.\n\n` +
|
||||
`Reserved in Supports: ${wallet.result.reserved_subtotals.supports} LBC\n` +
|
||||
`Total: ${wallet.result.total} LBC` +
|
||||
(account.newAccount ? '\n\n:warning: This account was just created. ' +
|
||||
'Please wait a few seconds, and run the command again to get an accurate balance.' : '')
|
||||
} });
|
||||
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();
|
||||
if (await this.handleResponse(message, response, wallet)) return;
|
||||
return message.channel.createMessage({ embed: {
|
||||
color: config.embedColor,
|
||||
description: `You have **${wallet.result.available}** LBC available.\n\n` +
|
||||
`Reserved in Supports: ${wallet.result.reserved_subtotals.supports} LBC\n` +
|
||||
`Total: ${wallet.result.total} LBC` +
|
||||
(account.newAccount ? '\n\n:warning: This account was just created. ' +
|
||||
'Please wait a few seconds, and run the command again to get an accurate balance.' : '')
|
||||
} });
|
||||
}
|
||||
}
|
||||
|
||||
get metadata() { return {
|
||||
|
|
Loading…
Add table
Reference in a new issue