JaBa/helpers/discordbots.org.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const DBL = require("dblapi.js");
/* THIS POSTS STATS TO DISCORDBOTS.ORG */
module.exports = {
/**
* Starts to post stats to DBL
* @param {object} client The Discord Client instance
*/
2021-12-11 21:08:37 +05:00
init(client) {
2021-12-10 21:39:54 +05:00
if (client.config.apiKeys.dbl && client.config.apiKeys.dbl !== "") {
const stats = new DBL(client.config.apiKeys.dbl, client);
2021-12-11 21:08:37 +05:00
setInterval(function() {
2021-12-10 21:39:54 +05:00
stats.postStats(client.guilds.cache.size);
}, 10 * 60000); // every 10 minutes
const dbl = new DBL(client.config.apiKeys.dbl, { webhookPort: client.config.votes.port, webhookAuth: client.config.votes.password });
dbl.webhook.on("vote", async (vote) => {
const dUser = await client.users.fetch(vote.user);
const member = await client.findOrCreateMember({ id: vote.user, guildID: client.config.support.id });
member.money = member.money + 40;
member.save();
dUser.send(client.translate("misc:VOTE_DM", {
user: dUser.tag
})).catch(() => {});
const logsChannel = client.channels.cache.get(client.config.votes.channel);
2021-12-16 23:42:58 +05:00
if (logsChannel) logsChannel.send(client.translate("misc:VOTE_LOGS", { userid: dUser.id, usertag: dUser.tag }));
2021-12-10 21:39:54 +05:00
});
};
}
};