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,7 +9,8 @@ module.exports = class AbaondonAll extends Command {
permissions: ['Admin'],
minimumArgs: 0
}; }
//@TODO: Refactor this command for all abandons.
// @TODO: Refactor this command for all abandons.
async exec(message, { args }) {
const givenClaim = args[0];
if (!/^[a-f0-9]{40}$/.test(givenClaim))

View file

@ -13,12 +13,13 @@ module.exports = class DeleteAccount extends Command {
async exec(message, { args }) {
const discordID = Util.resolveToUserID(args[0]);
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);
if (account.accountID) {
const supportsCount = await Util.LBRY.getSupportsCount(this.client, account.accountID);
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;
await Util.LBRY.deleteAccount(this.client, discordID, account.accountID);
return message.channel.createMessage('Deleted account.');

View file

@ -1,11 +1,11 @@
const Command = require('../../structures/Command');
const Util = require('../../util');
module.exports = class FundAccount extends Command {
get name() { return 'fundaccount'; }
module.exports = class Fund extends Command {
get name() { return 'fund'; }
get _options() { return {
aliases: ['fund', 'fundacc'],
aliases: ['fundacc', 'fundaccount'],
permissions: ['admin'],
minimumArgs: 2
}; }
@ -14,14 +14,16 @@ module.exports = class FundAccount extends Command {
const givenAmount = Util.LBRY.ensureDecimal(args[1]);
if (!givenAmount)
return message.channel.createMessage('The second argument must be a numeric amount of LBC to send!');
const discordID = Util.resolveToUserID(args[0]);
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);
if (!await this.client.messageAwaiter.confirm(message, {
header: `Are you sure you want to fund this account? *(${givenAmount} LBC)*`
})) return;
const response = await this.client.lbry.fundAccount({to: account.accountID, amount: givenAmount});
const response = await this.client.lbry.fundAccount({ to: account.accountID, amount: givenAmount });
const transaction = await response.json();
console.info('Funded account', account.accountID, transaction.result.txid);
const txid = transaction.result.txid;

View file

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

View file

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

View file

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