mirror of
https://github.com/LBRYFoundation/curate.git
synced 2025-08-23 09:27:24 +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) {
|
||||
const supportsCount = await Util.LBRY.getSupportsCount(this.client, account.accountID);
|
||||
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;
|
||||
await Util.LBRY.deleteAccount(this.client, discordID, account.accountID);
|
||||
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');
|
||||
|
||||
module.exports = class Supports extends Command {
|
||||
get name() { return 'supports'; }
|
||||
get _options() { return {
|
||||
aliases: ['sups'],
|
||||
permissions: ['curatorOrAdmin'],
|
||||
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);
|
||||
} else {
|
||||
const account = await Util.LBRY.findOrCreateAccount(this.client, message.author.id);
|
||||
}
|
||||
const supportsCount = await Util.LBRY.getSupportsCount(client, account.accountID);
|
||||
if(!givenClaim) {
|
||||
get name() { return 'supports'; }
|
||||
get _options() { return {
|
||||
aliases: ['sups'],
|
||||
permissions: ['curatorOrAdmin'],
|
||||
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);
|
||||
} else {
|
||||
const 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}\`\nClaim URL: \`${support.permanent_url}\`\nSupport Ammount: \`${support.amount}\`\n`);
|
||||
}
|
||||
}else {
|
||||
const supportsResponse = await client.lbry.listSupports({
|
||||
accountID: account.accountID, page_size: supportsCount });
|
||||
console.debug(`Displaying supports for ${account.accountID} (${supportsCount})`);
|
||||
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;
|
||||
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({
|
||||
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;
|
||||
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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
get metadata() { return {
|
||||
category: 'Curator',
|
||||
description: 'Shows the user\'s list of supports.',
|
||||
usage: '[claimID] [mention/discordID]'
|
||||
}; }
|
||||
}
|
||||
}
|
||||
}
|
||||
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