mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 17:37:25 +00:00
Fixed typo in deleteAccount, Added Fund command
This commit is contained in:
parent
456a50d868
commit
15e871f670
3 changed files with 82 additions and 46 deletions
|
@ -18,7 +18,7 @@ module.exports = class DeleteAccount extends Command {
|
||||||
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 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.');
|
||||||
|
|
36
src/commands/admin/fund.js
Normal file
36
src/commands/admin/fund.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
const Command = require('../../structures/Command');
|
||||||
|
const Util = require('../../util');
|
||||||
|
|
||||||
|
module.exports = class FundAccount extends Command {
|
||||||
|
get name() { return 'fundaccount'; }
|
||||||
|
|
||||||
|
get _options() { return {
|
||||||
|
aliases: ['fund', 'fundacc'],
|
||||||
|
permissions: ['admin'],
|
||||||
|
minimumArgs: 2
|
||||||
|
}; }
|
||||||
|
|
||||||
|
async exec(message, { args }) {
|
||||||
|
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.');
|
||||||
|
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 transaction = await response.json();
|
||||||
|
console.info('Funded account', account.result.id, transaction.result.txid);
|
||||||
|
const txid = transaction.result.txid;
|
||||||
|
return message.channel.createMessage(`Successfully funded account! https://explorer.lbry.com/tx/${txid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
get metadata() { return {
|
||||||
|
category: 'Admin',
|
||||||
|
description: 'Funds a given Discord user\'s Curation account with the specified amount of LBC.',
|
||||||
|
usage: '<id|@mention> <amount>'
|
||||||
|
}; }
|
||||||
|
};
|
|
@ -2,54 +2,54 @@ const Command = require('../../structures/Command');
|
||||||
const Util = require('../../util');
|
const Util = require('../../util');
|
||||||
|
|
||||||
module.exports = class Supports extends Command {
|
module.exports = class Supports extends Command {
|
||||||
get name() { return 'supports'; }
|
get name() { return 'supports'; }
|
||||||
get _options() { return {
|
get _options() { return {
|
||||||
aliases: ['sups'],
|
aliases: ['sups'],
|
||||||
permissions: ['curatorOrAdmin'],
|
permissions: ['curatorOrAdmin'],
|
||||||
minimumArgs: 0
|
minimumArgs: 0
|
||||||
}; }
|
}; }
|
||||||
async exec(message, { args }) {
|
async exec(message, { args }) {
|
||||||
if(args.count = 2) {
|
if(args.count = 2) {
|
||||||
const givenClaim = args[0];
|
const 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
|
// @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.');
|
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);
|
||||||
} else if (args.count = 1) {
|
} else if (args.count = 1) {
|
||||||
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.');
|
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);
|
||||||
} else {
|
} else {
|
||||||
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
|
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
|
||||||
}
|
}
|
||||||
const supportsCount = await Util.LBRY.getSupportsCount(client, account.accountID);
|
const supportsCount = await Util.LBRY.getSupportsCount(client, account.accountID);
|
||||||
if(!givenClaim) {
|
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}\`\nClaim URL: \`${support.permanent_url}\`\nSupport Ammount: \`${support.amount}\`\n`);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
const supportsResponse = await client.lbry.listSupports({
|
const supportsResponse = await client.lbry.listSupports({
|
||||||
accountID: account.accountID, page_size: supportsCount });
|
accountID: account.accountID, page_size: supportsCount, claim_id: givenClaim });
|
||||||
console.debug(`Displaying supports for ${account.accountID} (${supportsCount})`);
|
console.debug(`Displaying supports for ${account.accountID} and claimID ${givenClaim}, (${supportsCount})`);
|
||||||
const supports = (await supportsResponse.json()).result.items;
|
const supports = (await supportsResponse.json()).result.items;
|
||||||
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}\`\nClaim URL: \`${support.permanent_url}\`\nSupport Ammount: \`${support.amount}\`\n`);
|
message.channel.createMessage(`ClaimID: \`${support.claim_id}\`\nClaim Name: \`${support.name}\`\nClaim 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 });
|
get metadata() { return {
|
||||||
console.debug(`Displaying supports for ${account.accountID} and claimID ${givenClaim}, (${supportsCount})`);
|
category: 'Curator',
|
||||||
const supports = (await supportsResponse.json()).result.items;
|
description: 'Shows the user\'s list of supports.',
|
||||||
for (let i = 0, len = supports.length; i < len; i++) {
|
usage: '[claimID] [mention/discordID]'
|
||||||
const support = supports[i];
|
}; }
|
||||||
message.channel.createMessage(`ClaimID: \`${support.claim_id}\`\nClaim Name: \`${support.name}\`\nClaim URL: \`${support.permanent_url}\`\nSupport Ammount: \`${support.amount}\`\n`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get metadata() { return {
|
|
||||||
category: 'Curator',
|
|
||||||
description: 'Shows the user\'s list of supports.',
|
|
||||||
usage: '[claimID] [mention/discordID]'
|
|
||||||
}; }
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue