mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-09 18:39:35 +02:00
Remove 15 commands, patreon and bot list stuff
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
const request = require('node-superfetch');
|
||||
const {
|
||||
TOP_GG_TOKEN,
|
||||
BOTS_GG_TOKEN,
|
||||
DISCORDBOTLIST_TOKEN,
|
||||
CARBON_TOKEN,
|
||||
BLIST_TOKEN
|
||||
} = process.env;
|
||||
|
||||
module.exports = class BotList {
|
||||
constructor(client) {
|
||||
Object.defineProperty(this, 'client', { value: client });
|
||||
|
||||
this.topGGToken = TOP_GG_TOKEN;
|
||||
this.botsGGToken = BOTS_GG_TOKEN;
|
||||
this.discordBotsListToken = DISCORDBOTLIST_TOKEN;
|
||||
this.carbonToken = CARBON_TOKEN;
|
||||
this.blistToken = BLIST_TOKEN;
|
||||
}
|
||||
|
||||
async postTopGGStats() {
|
||||
if (!this.topGGToken) return null;
|
||||
try {
|
||||
const { body } = await request
|
||||
.post(`https://top.gg/api/bots/${this.client.user.id}/stats`)
|
||||
.set({ Authorization: this.topGGToken })
|
||||
.send({ server_count: this.client.guilds.cache.size });
|
||||
this.client.logger.info('[TOP.GG] Posted stats.');
|
||||
return body;
|
||||
} catch (err) {
|
||||
this.client.logger.error(`[TOP.GG] Failed to post stats:\n${err.stack}`);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
async postBotsGGStats() {
|
||||
if (!this.botsGGToken) return null;
|
||||
try {
|
||||
const { body } = await request
|
||||
.post(`https://discord.bots.gg/api/v1/bots/${this.client.user.id}/stats`)
|
||||
.set({ Authorization: this.botsGGToken })
|
||||
.send({ guildCount: this.client.guilds.cache.size });
|
||||
this.client.logger.info('[BOTS.GG] Posted stats.');
|
||||
return body;
|
||||
} catch (err) {
|
||||
this.client.logger.error(`[BOTS.GG] Failed to post stats:\n${err.stack}`);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
async postDiscordBotListStats() {
|
||||
if (!this.discordBotsListToken) return null;
|
||||
try {
|
||||
const { body } = await request
|
||||
.post(`https://discordbotlist.com/api/v1/bots/${this.client.user.id}/stats`)
|
||||
.set({ Authorization: this.discordBotsListToken })
|
||||
.send({
|
||||
guilds: this.client.guilds.cache.size,
|
||||
users: this.client.users.cache.size,
|
||||
voice_connections: this.client.dispatchers.size
|
||||
});
|
||||
this.client.logger.info('[DISCORDBOTLIST] Posted stats.');
|
||||
return body;
|
||||
} catch (err) {
|
||||
this.client.logger.error(`[DISCORDBOTLIST] Failed to post stats:\n${err.stack}`);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
async postCarbonStats() {
|
||||
if (!this.carbonToken) return null;
|
||||
try {
|
||||
const { body } = await request
|
||||
.post('https://www.carbonitex.net/discord/data/botdata.php')
|
||||
.send({
|
||||
key: this.carbonToken,
|
||||
servercount: this.client.guilds.cache.size,
|
||||
botid: this.client.user.id
|
||||
});
|
||||
this.client.logger.info('[CARBON] Posted stats.');
|
||||
return body;
|
||||
} catch (err) {
|
||||
this.client.logger.error(`[CARBON] Failed to post stats:\n${err.stack}`);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
async postBlistStats() {
|
||||
if (!this.blistToken) return null;
|
||||
try {
|
||||
const { body } = await request
|
||||
.patch(`https://blist.xyz/api/v2/bot/${this.client.user.id}/stats/`)
|
||||
.set({ Authorization: this.blistToken })
|
||||
.send({ server_count: this.client.guilds.cache.size });
|
||||
this.client.logger.info('[BLIST] Posted stats.');
|
||||
return body;
|
||||
} catch (err) {
|
||||
this.client.logger.error(`[BLIST] Failed to post stats:\n${err.stack}`);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
};
|
||||
+1
-14
@@ -1,5 +1,4 @@
|
||||
const CommandClient = require('../framework/Client');
|
||||
const { WebhookClient } = require('discord.js');
|
||||
const request = require('node-superfetch');
|
||||
const { Collection } = require('@discordjs/collection');
|
||||
const winston = require('winston');
|
||||
@@ -11,19 +10,12 @@ const url = require('url');
|
||||
const path = require('path');
|
||||
const Redis = require('./Redis');
|
||||
const Font = require('./Font');
|
||||
const BotList = require('./BotList');
|
||||
const PhoneManager = require('./phone/PhoneManager');
|
||||
const TimerManager = require('./remind/TimerManager');
|
||||
const PokemonStore = require('./pokemon/PokemonStore');
|
||||
const activities = require('../assets/json/activity');
|
||||
const leaveMsgs = require('../assets/json/leave-messages');
|
||||
const {
|
||||
XIAO_WEBHOOK_ID,
|
||||
XIAO_WEBHOOK_TOKEN,
|
||||
REPORT_CHANNEL_ID,
|
||||
JOIN_LEAVE_CHANNEL_ID,
|
||||
COMMAND_CHANNEL_ID
|
||||
} = process.env;
|
||||
const { REPORT_CHANNEL_ID, JOIN_LEAVE_CHANNEL_ID, COMMAND_CHANNEL_ID } = process.env;
|
||||
|
||||
module.exports = class XiaoClient extends CommandClient {
|
||||
constructor(options) {
|
||||
@@ -38,12 +30,7 @@ module.exports = class XiaoClient extends CommandClient {
|
||||
});
|
||||
this.fonts = new Collection();
|
||||
this.redis = Redis ? Redis.db : null;
|
||||
this.webhook = new WebhookClient(
|
||||
{ id: XIAO_WEBHOOK_ID, token: XIAO_WEBHOOK_TOKEN },
|
||||
{ disableMentions: 'everyone' }
|
||||
);
|
||||
this.timers = new TimerManager(this);
|
||||
this.botList = new BotList(this);
|
||||
this.pokemon = new PokemonStore();
|
||||
this.games = new Collection();
|
||||
this.dispatchers = new Map();
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
const request = require('node-superfetch');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { PATREON_ACCESS_TOKEN, PATREON_CAMPAIGN_ID } = process.env;
|
||||
|
||||
module.exports = class Patreon {
|
||||
constructor(accessToken, campaignID) {
|
||||
this.patrons = [];
|
||||
this.forced = [];
|
||||
this.accessToken = accessToken || PATREON_ACCESS_TOKEN;
|
||||
this.campaignID = campaignID || PATREON_CAMPAIGN_ID;
|
||||
}
|
||||
|
||||
isPatron(id) {
|
||||
return this.patrons.includes(id) || this.forced.includes(id);
|
||||
}
|
||||
|
||||
async fetchPatrons() {
|
||||
if (!this.accessToken || !this.campaignID) return null;
|
||||
const { text } = await request
|
||||
.get(`https://www.patreon.com/api/oauth2/v2/campaigns/${PATREON_CAMPAIGN_ID}/members`)
|
||||
.set({ Authorization: `Bearer ${PATREON_ACCESS_TOKEN}` })
|
||||
.query({
|
||||
include: 'currently_entitled_tiers,user',
|
||||
'fields[user]': 'social_connections',
|
||||
'fields[member]': 'patron_status'
|
||||
});
|
||||
const body = JSON.parse(text);
|
||||
const patrons = [];
|
||||
for (const patron of body.data) {
|
||||
if (patron.attributes.patron_status !== 'active_patron') continue;
|
||||
const socials = body.included.find(user => user.id === patron.relationships.user.data.id)
|
||||
?.attributes?.social_connections;
|
||||
if (!socials || !socials.discord || !socials.discord.user_id) continue;
|
||||
patrons.push(socials.discord.user_id);
|
||||
}
|
||||
this.patrons = patrons;
|
||||
return this.patrons;
|
||||
}
|
||||
|
||||
importForced() {
|
||||
const read = fs.readFileSync(path.join(__dirname, '..', 'patreon.json'), { encoding: 'utf8' });
|
||||
const file = JSON.parse(read);
|
||||
if (!Array.isArray(file)) return null;
|
||||
for (const id of file) {
|
||||
if (typeof id !== 'string') continue;
|
||||
if (this.forced.includes(id)) continue;
|
||||
this.forced.push(id);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
exportForced() {
|
||||
let text = '[\n ';
|
||||
if (this.forced.length) {
|
||||
for (const id of this.forced) {
|
||||
text += `"${id}",\n `;
|
||||
}
|
||||
text = text.slice(0, -3);
|
||||
}
|
||||
text += '\n]\n';
|
||||
const buf = Buffer.from(text);
|
||||
fs.writeFileSync(path.join(__dirname, '..', 'patreon.json'), buf, { encoding: 'utf8' });
|
||||
return buf;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user