mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +00:00
Add Abandon command
This commit is contained in:
parent
50e4ae63e1
commit
89339e801f
1 changed files with 39 additions and 0 deletions
39
src/commands/curator/abandon.js
Normal file
39
src/commands/curator/abandon.js
Normal 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>'
|
||||
}; }
|
||||
};
|
Loading…
Add table
Reference in a new issue