diff --git a/src/client.ts b/src/client.ts index aec5e9db..430f23e4 100644 --- a/src/client.ts +++ b/src/client.ts @@ -29,7 +29,7 @@ import { ModerationService } from './moderation/services/Moderation'; import { MusicCache } from './music/cache/MusicCache'; import { MusicService } from './music/services/MusicService'; import { botDefaultSettings, BotSettingsObject, guildDefaultSettings } from './settings'; -import { BotType, ChannelType, GatewayInfo, LavaPlayerManager } from './types'; +import { BotType, ChannelType, LavaPlayerManager } from './types'; i18n.configure({ locales: ['cs', 'de', 'en', 'es', 'fr', 'it', 'ja', 'nl', 'pl', 'pt', 'pt_BR', 'ro', 'ru', 'tr'], @@ -114,11 +114,6 @@ export class IMClient extends Client { cmdHttpErrors: Map; }; - private counts: { - cachedAt: Moment; - guilds: number; - members: number; - }; public disabledGuilds: Set = new Set(); public constructor({ version, token, type, instance, shardId, shardCount, flags, config }: ClientOptions) { @@ -148,11 +143,6 @@ export class IMClient extends Client { cmdErrors: 0, cmdHttpErrors: new Map() }; - this.counts = { - cachedAt: moment.unix(0), - guilds: 0, - members: 0 - }; this.version = version; this.type = type; @@ -544,25 +534,6 @@ export class IMClient extends Client { }); } - public async getCounts() { - // If cached data is older than 12 hours, update it - if ( - moment() - .subtract(4, 'hours') - .isAfter(this.counts.cachedAt) - ) { - console.log('Fetching data counts from DB...'); - const stats = await this.db.getDbStats(); - this.counts = { - cachedAt: moment(), - guilds: stats.guilds, - members: stats.members - }; - } - - return this.counts; - } - public async setActivity() { const status = this.settings.activityStatus; @@ -571,8 +542,6 @@ export class IMClient extends Client { return; } - const counts = await this.getCounts(); - const type = this.settings.activityType === 'playing' ? 0 @@ -584,11 +553,7 @@ export class IMClient extends Client { ? 3 : 0; - let name = `invitemanager.co - ${counts.guilds} servers!`; - if (this.settings.activityMessage) { - name = this.settings.activityMessage.replace(/{serverCount}/gi, counts.guilds.toString()); - } - + const name = this.settings.activityMessage || `docs.invitemanager.co!`; const url = this.settings.activityUrl; this.editStatus(status, { name, type, url }); diff --git a/src/framework/commands/info/botInfo.ts b/src/framework/commands/info/botInfo.ts index 1009b84c..3b08961c 100644 --- a/src/framework/commands/info/botInfo.ts +++ b/src/framework/commands/info/botInfo.ts @@ -24,8 +24,6 @@ export default class extends Command { ): Promise { const lang = settings.lang; - const counts = await this.client.getCounts(); - const embed = this.createEmbed(); // Version @@ -45,31 +43,12 @@ export default class extends Command { inline: true }); - // Guild count - embed.fields.push({ - name: t('cmd.botInfo.guilds'), - value: counts.guilds.toString(), - inline: true - }); - - // Member count - embed.fields.push({ - name: t('cmd.botInfo.members'), - value: counts.members.toString(), - inline: true - }); - // Shard info embed.fields.push({ name: t('cmd.botInfo.shards.current'), value: `${this.client.shardId} (${this.client.db.getDbShardForGuild(guild.id)})`, inline: true }); - embed.fields.push({ - name: t('cmd.botInfo.shards.total'), - value: this.client.shardCount.toString(), - inline: true - }); // Premium embed.fields.push({ diff --git a/src/framework/models/DBStat.ts b/src/framework/models/DBStat.ts deleted file mode 100644 index 7690e905..00000000 --- a/src/framework/models/DBStat.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class DBStat { - public key: string; - public createdAt?: Date; - public updatedAt?: Date; - public value: number; -} diff --git a/src/framework/services/DatabaseService.ts b/src/framework/services/DatabaseService.ts index b0d06156..63b5af30 100644 --- a/src/framework/services/DatabaseService.ts +++ b/src/framework/services/DatabaseService.ts @@ -16,7 +16,6 @@ import { getShardIdForGuild } from '../../util'; import { BotSetting } from '../models/BotSetting'; import { Channel } from '../models/Channel'; import { CommandUsage } from '../models/CommandUsage'; -import { DBStat } from '../models/DBStat'; import { Guild } from '../models/Guild'; import { GuildSetting } from '../models/GuildSetting'; import { Incident } from '../models/Incident'; @@ -799,17 +798,6 @@ export class DatabaseService { await this.insertOrUpdate(TABLE.incidents, ['guildId', 'error', 'details'], [], indicents, i => i.guildId); } - // ------------ - // DB stats - // ------------ - public async getDbStats() { - const stats = await this.findMany(GLOBAL_SHARD_ID, TABLE.dbStats, '`key` IN(?)', [['guilds', 'members']]); - return { - guilds: stats.find(stat => stat.key === 'guilds').value, - members: stats.find(stat => stat.key === 'members').value - }; - } - // --------------- // Music nodes // ---------------