diff --git a/src/commands/admin/allsupports.js b/src/commands/admin/allsupports.js new file mode 100644 index 0000000..eaaf8c0 --- /dev/null +++ b/src/commands/admin/allsupports.js @@ -0,0 +1,60 @@ +const Command = require('../../structures/Command'); +const Util = require('../../util'); +const GenericPager = require('../../structures/GenericPager'); + +module.exports = class AllSupports extends Command { + get name() { return 'allsupports'; } + + get _options() { return { + aliases: ['asups', 'allsups'], + permissions: ['admin'], + minimumArgs: 1 + }; } + + async exec(message, { args }) { + let givenClaim; + if (args[0]) { + givenClaim = Util.resolveToClaimID(args[0]); + if (!givenClaim) + // @TODO use claim_search for invalid claim ids + return message.channel.createMessage('That Claim ID isn\'t valid.'); + } + + await Util.LBRY.syncPairs(this.client); + const pairs = await this.client.sqlite.getAll(); + if (pairs.length <= 0) + return message.channel.createMessage('No users found in the database.'); + + const allSupports = []; + + for (const pair of pairs) { + const supportsCount = await Util.LBRY.getSupportsCount(this.client, pair.lbryID); + if (supportsCount <= 0) continue; + const supportsResponse = await this.client.lbry.listSupports({ + accountID: pair.lbryID, page_size: supportsCount, claimID: givenClaim }); + const supports = (await supportsResponse.json()).result.items; + for (const support of supports) + allSupports.push({ + ...support, + pair + }); + } + + if (allSupports.length <= 0) + return message.channel.createMessage('No supports found.'); + + const paginator = new GenericPager(this.client, message, { + items: allSupports, + header: `All supports${ + givenClaim ? ` on claim \`${givenClaim}\`` : ''}`, itemTitle: 'Supports',itemsPerPage: 5, + display: item => `> ${item.name} \`${item.claim_id}\`\n> <@${item.pair.discordID}> ${item.amount} LBC\n` + }); + return paginator.start(message.channel.id, message.author.id); + } + + get metadata() { return { + category: 'Admin', + description: 'List all supports from all users.', + usage: '[claimID]' + }; } +}; diff --git a/src/commands/admin/listall.js b/src/commands/admin/listall.js index 618c1ac..09b94d1 100644 --- a/src/commands/admin/listall.js +++ b/src/commands/admin/listall.js @@ -43,6 +43,7 @@ module.exports = class ListAll extends Command { } get metadata() { return { category: 'Admin', - description: 'List all users in the database.' + description: 'List all users in the database.', + usage: '[page]' }; } }; diff --git a/src/commands/curator/supports.js b/src/commands/curator/supports.js index 5819ac9..ddd9d28 100644 --- a/src/commands/curator/supports.js +++ b/src/commands/curator/supports.js @@ -49,7 +49,7 @@ module.exports = class Supports extends Command { items: supports, header: `All supports for <@${discordID || message.author.id}>${ givenClaim ? ` on claim \`${givenClaim}\`` : ''}`, itemTitle: 'Supports',itemsPerPage: 5, - display: item => `> ${item.name} #\`${item.claim_id}\`\n> ${item.amount} LBC\n` + display: item => `> ${item.name} \`${item.claim_id}\`\n> ${item.amount} LBC\n` }); return paginator.start(message.channel.id, message.author.id); } diff --git a/src/commands/trusted/tsupports.js b/src/commands/trusted/tsupports.js index c6bd5a2..fe26636 100644 --- a/src/commands/trusted/tsupports.js +++ b/src/commands/trusted/tsupports.js @@ -30,7 +30,7 @@ module.exports = class TSupports extends Command { items: supports, header: `All supports for the trusted account${ givenClaim ? ` on claim \`${givenClaim}\`` : ''}`, itemTitle: 'Supports', itemsPerPage: 5, - display: item => `> ${item.name} #\`${item.claim_id}\`\n> ${item.amount} LBC\n` + display: item => `> ${item.name} \`${item.claim_id}\`\n> ${item.amount} LBC\n` }); return paginator.start(message.channel.id, message.author.id); }