mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-19 21:40:51 +02:00
Upvoters Command
This commit is contained in:
@@ -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).
|
||||||
|
|||||||
@@ -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}>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user