Upvoters Command

This commit is contained in:
Daniel Odendahl Jr
2017-07-12 15:02:51 +00:00
parent 0e71a0963d
commit b1bfeaa959
3 changed files with 37 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ JavaScript with [discord.js](https://github.com/hydrabolt/discord.js) using the
## Adding it to Your Server ## Adding it to Your Server
Visit XiaoBot's page on the Discord Bots list, which is quite fancy, with Visit XiaoBot's page on the Discord Bots list, which is quite fancy, with
[this link](https://bots.discord.pw/bots/278305350804045834). [this link](https://discordbots.org/bot/278305350804045834).
## Home Server ## Home Server
You can join the home server with [this link](https://discord.gg/fqQF8mc). You can join the home server with [this link](https://discord.gg/fqQF8mc).
+29
View File
@@ -0,0 +1,29 @@
const Command = require('../../structures/Command');
const snekfetch = require('snekfetch');
const { stripIndents } = require('common-tags');
const { upvoters } = require('../../structures/Util');
module.exports = class UpvotersCommand extends Command {
constructor(client) {
super(client, {
name: 'upvoters',
aliases: ['upvote'],
group: 'util',
memberName: 'upvoters',
description: 'Responds with Xiao\'s upvoters on Discord Bots.',
guarded: true
});
}
async run(msg) {
const upvotes = await upvoters(this.client.user.id);
const { body } = await snekfetch
.post('https://hastebin.com/documents')
.send(upvotes.join('\n'));
return msg.say(stripIndents`
Upvote Xiao and join ${upvotes.length} others!
<https://discordbots.org/bot/${this.client.user.id}>
List of Upvoters: <https://hastebin.com/${body.key}>
`);
}
};
+7
View File
@@ -39,6 +39,13 @@ class Util {
.then(() => console.log('[DBOTSORG] Successfully posted to Discord Bots Org.')) .then(() => console.log('[DBOTSORG] Successfully posted to Discord Bots Org.'))
.catch((err) => console.error(`[DBOTSORG] Failed to post to Discord Bots Org. ${err}`)); .catch((err) => console.error(`[DBOTSORG] Failed to post to Discord Bots Org. ${err}`));
} }
async static upvoters(id) {
const { body } = await snekfetch
.get(`https://discordbots.org/api/bots/${id}/votes`)
.set({ Authorization: dbotsOrgKey });
return body.map((user) => `${user.username}#${user.discriminator}`);
}
} }
module.exports = Util; module.exports = Util;