const snekfetch = require('snekfetch'); const { carbonKey, dbotsKey, dbotsOrgKey } = require('../config'); class Util { static cleanXML(str) { return str .replace(/(
)/g, '') .replace(/(')/g, '\'') .replace(/(—)/g, '—') .replace(/("|")/g, '"') .replace(/(&)/g, '&') .replace(/(\[i\]|\[\/i\])/g, '*'); } static dBots(count, id) { snekfetch .post(`https://bots.discord.pw/api/bots/${id}/stats`) .set({ Authorization: dbotsKey }) .send({ server_count: count }) .then(() => console.log('[DBOTS] Successfully posted to Discord Bots.')) .catch((err) => console.error(`[DBOTS] Failed to post to Discord Bots. ${err}`)); } static carbon(count) { snekfetch .post('https://www.carbonitex.net/discord/data/botdata.php') .send({ key: carbonKey, servercount: count }) .then(() => console.log('[CARBON] Successfully posted to Carbon.')) .catch((err) => console.error(`[CARBON] Failed to post to Carbon. ${err}`)); } static dBotsOrg(count, id) { snekfetch .post(`https://discordbots.org/api/bots/${id}/stats`) .set({ Authorization: dbotsOrgKey }) .send({ server_count: count }) .then(() => console.log('[DBOTSORG] Successfully posted to Discord Bots Org.')) .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;