mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +00:00
Fix some commands
This commit is contained in:
parent
de6609d609
commit
f4f7e19f95
4 changed files with 23 additions and 27 deletions
|
@ -10,26 +10,27 @@ module.exports = class AbaondonAll extends Command {
|
||||||
minimumArgs: 0
|
minimumArgs: 0
|
||||||
}; }
|
}; }
|
||||||
|
|
||||||
// @TODO: Refactor this command for all abandons.
|
// @TODO: Refactor this command to be able to abandon all supports on the bot.
|
||||||
async exec(message, { args }) {
|
async exec(message, { args }) {
|
||||||
const givenClaim = args[0];
|
const discordID = Util.resolveToUserID(args[0]);
|
||||||
if (!/^[a-f0-9]{40}$/.test(givenClaim))
|
if (!discordID)
|
||||||
// @TODO use claim_search for invalid claim ids
|
return message.channel.createMessage('That Discord user isn\'t valid.');
|
||||||
return message.channel.createMessage('That Claim ID isn\'t valid.');
|
const account = await Util.LBRY.findOrCreateAccount(this.client, discordID, false);
|
||||||
|
if (!account.accountID)
|
||||||
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
|
return message.channel.createMessage('That user does not have an account.');
|
||||||
if (account.newAccount) {
|
|
||||||
// Wait for the blockchain to complete the funding
|
const supportsCount = await Util.LBRY.getSupportsCount(this.client, account.accountID);
|
||||||
await message.channel.sendTyping();
|
if (supportsCount <= 0)
|
||||||
await Util.halt(3000);
|
return message.channel.createMessage('That user does not have any supports.');
|
||||||
}
|
|
||||||
// Create support
|
if (!await this.client.messageAwaiter.confirm(message, {
|
||||||
const response = await this.client.lbry.abandonSupport({
|
header:
|
||||||
accountID: account.accountID, claimID: givenClaim});
|
`Are you sure you want to abandon all supports from that account? *(${
|
||||||
const transaction = await response.json();
|
supportsCount.toLocaleString()} support[s])*`
|
||||||
if (await this.handleResponse(message, response, transaction)) return;
|
})) return;
|
||||||
const txid = transaction.result.txid;
|
const response = await Util.LBRY.abandonAllClaims(this.client, account.accountID);
|
||||||
message.channel.createMessage(`Abandon successful! https://explorer.lbry.com/tx/${txid}`);
|
if (await this.handleResponse(message, response)) return;
|
||||||
|
return message.channel.createMessage('Abandoned all claims.');
|
||||||
}
|
}
|
||||||
|
|
||||||
get metadata() { return {
|
get metadata() { return {
|
||||||
|
|
|
@ -19,7 +19,7 @@ module.exports = class Fund extends Command {
|
||||||
if (!discordID)
|
if (!discordID)
|
||||||
return 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);
|
||||||
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)*`
|
||||||
})) return;
|
})) return;
|
||||||
|
|
|
@ -17,11 +17,6 @@ module.exports = class Abaondon extends Command {
|
||||||
return message.channel.createMessage('That Claim ID isn\'t valid.');
|
return message.channel.createMessage('That Claim ID isn\'t valid.');
|
||||||
|
|
||||||
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop support
|
// Drop support
|
||||||
const response = await this.client.lbry.abandonSupport({
|
const response = await this.client.lbry.abandonSupport({
|
||||||
|
@ -29,7 +24,7 @@ module.exports = class Abaondon extends Command {
|
||||||
const transaction = await response.json();
|
const transaction = await response.json();
|
||||||
if (await this.handleResponse(message, response, transaction)) return;
|
if (await this.handleResponse(message, response, transaction)) return;
|
||||||
const txid = transaction.result.txid;
|
const txid = transaction.result.txid;
|
||||||
message.channel.createMessage(`Abandon successful! https://explorer.lbry.com/tx/${txid}`);
|
return message.channel.createMessage(`Abandon successful! https://explorer.lbry.com/tx/${txid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
get metadata() { return {
|
get metadata() { return {
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = class Support extends Command {
|
||||||
const transaction = await response.json();
|
const transaction = await response.json();
|
||||||
if (await this.handleResponse(message, response, transaction)) return;
|
if (await this.handleResponse(message, response, transaction)) return;
|
||||||
const txid = transaction.result.txid;
|
const txid = transaction.result.txid;
|
||||||
message.channel.createMessage(`Support successful! https://explorer.lbry.com/tx/${txid}`);
|
return message.channel.createMessage(`Support successful! https://explorer.lbry.com/tx/${txid}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
get metadata() { return {
|
get metadata() { return {
|
||||||
|
|
Loading…
Add table
Reference in a new issue