Fix eslint errors

This commit is contained in:
Snazzah 2020-08-14 11:58:58 -05:00
parent 044946022a
commit de6609d609
No known key found for this signature in database
GPG key ID: 5E71D54F3D86282E
6 changed files with 58 additions and 43 deletions

View file

@ -9,6 +9,7 @@ module.exports = class AbaondonAll extends Command {
permissions: ['Admin'], permissions: ['Admin'],
minimumArgs: 0 minimumArgs: 0
}; } }; }
// @TODO: Refactor this command for all abandons. // @TODO: Refactor this command for all abandons.
async exec(message, { args }) { async exec(message, { args }) {
const givenClaim = args[0]; const givenClaim = args[0];

View file

@ -13,12 +13,13 @@ module.exports = class DeleteAccount extends Command {
async exec(message, { args }) { async exec(message, { args }) {
const discordID = Util.resolveToUserID(args[0]); const discordID = Util.resolveToUserID(args[0]);
if (!discordID) if (!discordID)
message.channel.createMessage('That Discord user isn\'t valid.'); return message.channel.createMessage('That Discord user isn\'t valid.');
const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false); const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false);
if (account.accountID) { if (account.accountID) {
const supportsCount = await Util.LBRY.getSupportsCount(this.client, account.accountID); const supportsCount = await Util.LBRY.getSupportsCount(this.client, account.accountID);
if (!await this.client.messageAwaiter.confirm(message, { if (!await this.client.messageAwaiter.confirm(message, {
header: `Are you sure you want to delete that account? *(${supportsCount.toLocaleString()} support[s])*` header:
`Are you sure you want to delete that account? *(${supportsCount.toLocaleString()} support[s])*`
})) return; })) return;
await Util.LBRY.deleteAccount(this.client, discordID, account.accountID); await Util.LBRY.deleteAccount(this.client, discordID, account.accountID);
return message.channel.createMessage('Deleted account.'); return message.channel.createMessage('Deleted account.');

View file

@ -1,11 +1,11 @@
const Command = require('../../structures/Command'); const Command = require('../../structures/Command');
const Util = require('../../util'); const Util = require('../../util');
module.exports = class FundAccount extends Command { module.exports = class Fund extends Command {
get name() { return 'fundaccount'; } get name() { return 'fund'; }
get _options() { return { get _options() { return {
aliases: ['fund', 'fundacc'], aliases: ['fundacc', 'fundaccount'],
permissions: ['admin'], permissions: ['admin'],
minimumArgs: 2 minimumArgs: 2
}; } }; }
@ -14,9 +14,11 @@ module.exports = class FundAccount extends Command {
const givenAmount = Util.LBRY.ensureDecimal(args[1]); const givenAmount = Util.LBRY.ensureDecimal(args[1]);
if (!givenAmount) if (!givenAmount)
return message.channel.createMessage('The second argument must be a numeric amount of LBC to send!'); return message.channel.createMessage('The second argument must be a numeric amount of LBC to send!');
const discordID = Util.resolveToUserID(args[0]); const discordID = Util.resolveToUserID(args[0]);
if (!discordID) if (!discordID)
message.channel.createMessage('That Discord user isn\'t valid.'); return message.channel.createMessage('That Discord user isn\'t valid.');
const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, true); const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, true);
if (!await this.client.messageAwaiter.confirm(message, { if (!await this.client.messageAwaiter.confirm(message, {
header: `Are you sure you want to fund this account? *(${givenAmount} LBC)*` header: `Are you sure you want to fund this account? *(${givenAmount} LBC)*`

View file

@ -22,7 +22,8 @@ module.exports = class Abaondon extends Command {
await message.channel.sendTyping(); await message.channel.sendTyping();
await Util.halt(3000); await Util.halt(3000);
} }
// Create support
// Drop support
const response = await this.client.lbry.abandonSupport({ const response = await this.client.lbry.abandonSupport({
accountID: account.accountID, claimID: givenClaim }); accountID: account.accountID, claimID: givenClaim });
const transaction = await response.json(); const transaction = await response.json();

View file

@ -9,40 +9,50 @@ module.exports = class Supports extends Command {
minimumArgs: 0 minimumArgs: 0
}; } }; }
async exec(message, { args }) { async exec(message, { args }) {
if(args.count === 2) { let account, givenClaim;
const givenClaim = args[0]; if (args.length === 2) {
// Check for if claim ID and discord user is given
givenClaim = args[0];
if (!/^[a-f0-9]{40}$/.test(givenClaim)) if (!/^[a-f0-9]{40}$/.test(givenClaim))
// @TODO use claim_search for invalid claim ids
return message.channel.createMessage('That Claim ID isn\'t valid.'); return message.channel.createMessage('That Claim ID isn\'t valid.');
const discordID = Util.resolveToUserID(args[1]); const discordID = Util.resolveToUserID(args[1]);
if (!discordID) if (!discordID)
message.channel.createMessage('That Discord user isn\'t valid.'); return message.channel.createMessage('That Discord user isn\'t valid.');
const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false); account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false);
} else if (args.count === 1) { } else if (args.length === 1) {
// Check for only if a discord user is given
const discordID = Util.resolveToUserID(args[0]); const discordID = Util.resolveToUserID(args[0]);
if (!discordID) if (!discordID)
message.channel.createMessage('That Discord user isn\'t valid.'); return message.channel.createMessage('That Discord user isn\'t valid.');
const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false); account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false);
} else { } else {
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id); // Default to message author
account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
} }
const supportsCount = await Util.LBRY.getSupportsCount(client, account.accountID);
if (!account.accountID)
return message.channel.createMessage('That Discord user does not have an account.');
const supportsCount = await Util.LBRY.getSupportsCount(this.client, account.accountID);
if (!givenClaim) { if (!givenClaim) {
const supportsResponse = await client.lbry.listSupports({ const supportsResponse = await this.client.lbry.listSupports({
accountID: account.accountID, page_size: supportsCount }); accountID: account.accountID, page_size: supportsCount });
console.debug(`Displaying supports for ${account.accountID} (${supportsCount})`); console.debug(`Displaying supports for ${account.accountID} (${supportsCount})`);
const supports = (await supportsResponse.json()).result.items; const supports = (await supportsResponse.json()).result.items;
// @TODO use pagination
for (let i = 0, len = supports.length; i < len; i++) { for (let i = 0, len = supports.length; i < len; i++) {
const support = supports[i]; const support = supports[i];
message.channel.createMessage(`ClaimID: \`${support.claim_id}\`\nClaim Name: \`${support.name}\`\n message.channel.createMessage(`ClaimID: \`${support.claim_id}\`\nClaim Name: \`${support.name}\`\n
Claim URL: \`${support.permanent_url}\`\nSupport Ammount: \`${support.amount}\`\n`); Claim URL: \`${support.permanent_url}\`\nSupport Ammount: \`${support.amount}\`\n`);
} }
} else { } else {
const supportsResponse = await client.lbry.listSupports({ const supportsResponse = await this.client.lbry.listSupports({
accountID: account.accountID, page_size: supportsCount, claim_id: givenClaim }); accountID: account.accountID, page_size: supportsCount, claim_id: givenClaim });
console.debug( console.debug(
`Displaying supports for ${account.accountID} and claimID ${givenClaim}, (${supportsCount})`); `Displaying supports for ${account.accountID} and claimID ${givenClaim}, (${supportsCount})`);
const supports = (await supportsResponse.json()).result.items; const supports = (await supportsResponse.json()).result.items;
// @TODO use pagination
for (let i = 0, len = supports.length; i < len; i++) { for (let i = 0, len = supports.length; i < len; i++) {
const support = supports[i]; const support = supports[i];
message.channel.createMessage(`ClaimID: \`${support.claim_id}\`\nClaim Name: \`${support.name}\`\n message.channel.createMessage(`ClaimID: \`${support.claim_id}\`\nClaim Name: \`${support.name}\`\n

View file

@ -149,7 +149,7 @@ Util.resolveToUserID = (arg) => {
* Make a promise that resolves after some time * Make a promise that resolves after some time
* @memberof Util. * @memberof Util.
* @param {string} arg * @param {string} arg
* @returns {?string} * @returns {Promise}
*/ */
Util.halt = (ms) => { Util.halt = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));