Add Abandon command

This commit is contained in:
Ralph S. (Coolguy3289) 2020-08-14 10:00:50 -04:00
parent 50e4ae63e1
commit 89339e801f

View file

@ -0,0 +1,39 @@
const Command = require('../../structures/Command');
const Util = require('../../util');
module.exports = class Abaondon extends Command {
get name() { return 'abandon'; }
get _options() { return {
aliases: ['aban', 'drop'],
permissions: ['curatorOrAdmin'],
minimumArgs: 1
}; }
async exec(message, { args }) {
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 account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
if (account.newAccount) {
// Wait for the blockchain to complete the funding
await message.channel.sendTyping();
await Util.halt(3000);
}
// Create support
const response = await this.client.lbry.abandonSupport({
accountID: account.accountID, claimID: givenClaim});
const transaction = await response.json();
if (await this.handleResponse(message, response, transaction)) return;
const txid = transaction.result.txid;
message.channel.createMessage(`Abandon successful! https://explorer.lbry.com/tx/${txid}`);
}
get metadata() { return {
category: 'Curator',
description: 'Abandons a support on a given claim.',
usage: '<claim>'
}; }
};