add !stars

This commit is contained in:
Ryan Cao 2022-05-22 13:44:29 +08:00
parent 97da087115
commit 84310fc1a2
No known key found for this signature in database
GPG key ID: 528A2C1B6656B97F

View file

@ -1,4 +1,5 @@
import type { Client, Message } from 'discord.js';
import fetch from 'node-fetch';
import pLimit from 'p-limit';
import { POLYCAT_CHANNEL_ID } from './constants';
@ -100,6 +101,21 @@ We probably can't fully fix this. If you find out which mod is causing this, tel
});
},
'!stars': async (c, e) => {
const count = await fetch('https://api.github.com/repos/PolyMC/PolyMC')
.then((r) => r.json() as Promise<{ stargazers_count: number }>)
.then((j) => j.stargazers_count);
await e.reply({
embeds: [
{
title: `${count} total stars!`,
color: 'GOLD',
},
],
});
},
'!polycatgen': async (c, e) => {
if (!e.guild) return;
if (e.channelId !== POLYCAT_CHANNEL_ID) return;