JaBa/helpers/discordbots.org.js

41 lines
1.2 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-26 19:29:37 +05:00
setInterval(function () {
2021-12-10 21:39:54 +05:00
stats.postStats(client.guilds.cache.size);
}, 10 * 60000); // every 10 minutes
2021-12-26 19:29:37 +05:00
const dbl = new DBL(client.config.apiKeys.dbl, {
webhookPort: client.config.votes.port,
webhookAuth: client.config.votes.password
});
2021-12-10 21:39:54 +05:00
dbl.webhook.on("vote", async (vote) => {
const dUser = await client.users.fetch(vote.user);
2021-12-26 19:29:37 +05:00
const member = await client.findOrCreateMember({
id: vote.user,
guildID: client.config.support.id
});
2021-12-30 20:03:36 +05:00
member.money = member.money + 50;
2021-12-10 21:39:54 +05:00
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
2022-01-03 23:20:33 +05:00
if (logsChannel) logsChannel.send({
content: client.translate("misc:VOTE_LOGS", {
userid: dUser.id,
usertag: dUser.tag
})
});
2021-12-10 21:39:54 +05:00
});
};
}
};