All files / src/lib top.gg-autoposter.ts

0% Statements 0/9
0% Branches 0/2
0% Functions 0/4
0% Lines 0/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                             
import { Logger } from "@nestjs/common";
import { DJSSharderPoster } from "topgg-autoposter";
import { ShardingManager } from "./";
 
export class TopGGAutoPoster extends DJSSharderPoster {
	public constructor(
		private readonly token: string,
		shardManager: ShardingManager,
	) {
		super(token, shardManager, {
			startPosting: false,
			postOnStart: true,
			interval: 36 * 100 * 1000, // 1 Hour
		});
	}
 
	private readonly logger = new Logger(TopGGAutoPoster.name);
 
	public async init() {
		this.start();
		if (this.started) {
			this.logger.log("Started");
		}
		this.on("posted", (stats) => {
			this.logger.log(`Posted stats to Top.gg | ${stats.serverCount} Server(s) | ${stats.shardCount} Shard(s)`);
		}).on("error", (error) => {
			this.logger.error(`Error when posting stats: ${error}`);
		});
	}
}