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']
|
permissions: ['curatorOrAdmin']
|
||||||
}; }
|
}; }
|
||||||
|
|
||||||
async exec(message) {
|
async exec(message, { args }) {
|
||||||
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
|
if (args.length) {
|
||||||
const response = await this.client.lbry.accountBalance(account.accountID);
|
if (!Util.CommandPermissions.admin(this.client, message)) {
|
||||||
const wallet = await response.json();
|
const admins = (Array.isArray(config.adminRoleID) ? config.adminRoleID : [config.adminRoleID])
|
||||||
if (await this.handleResponse(message, response, wallet)) return;
|
.map(id => `"${this.client.guilds.get(config.guildID).roles.get(id).name}"`);
|
||||||
return message.channel.createMessage({ embed: {
|
return message.channel.createMessage(
|
||||||
color: config.embedColor,
|
`You need to have the ${admins.join('/')} role(s) to see others balances!`);
|
||||||
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` +
|
const discordID = Util.resolveToUserID(args[0]);
|
||||||
(account.newAccount ? '\n\n:warning: This account was just created. ' +
|
if (!discordID)
|
||||||
'Please wait a few seconds, and run the command again to get an accurate balance.' : '')
|
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 {
|
get metadata() { return {
|
||||||
|
|
Loading…
Add table
Reference in a new issue