add rich presence
This commit is contained in:
parent
6df4c6f6e2
commit
dcd1d2a17d
2 changed files with 22 additions and 0 deletions
|
@ -22,6 +22,7 @@ import { join } from 'path';
|
||||||
|
|
||||||
import { green, bold, blue, underline, yellow } from 'kleur/colors';
|
import { green, bold, blue, underline, yellow } from 'kleur/colors';
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
|
import { getLatestMinecraft } from './utils/minecraftVersion';
|
||||||
|
|
||||||
export interface Command {
|
export interface Command {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -77,6 +78,12 @@ client.once('ready', async () => {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (client.user) {
|
||||||
|
client.user.presence.set({
|
||||||
|
activities: [{ name: `Minecraft ${await getLatestMinecraft()}` }],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
client.on('messageCreate', async (e) => {
|
client.on('messageCreate', async (e) => {
|
||||||
if (!e.content) return;
|
if (!e.content) return;
|
||||||
if (!e.channel.isText()) return;
|
if (!e.channel.isText()) return;
|
||||||
|
|
15
src/utils/minecraftVersion.ts
Normal file
15
src/utils/minecraftVersion.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
|
||||||
|
interface SimplifiedMetaVersion {
|
||||||
|
recommended: boolean;
|
||||||
|
type: 'release' | 'snapshot';
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getLatestMinecraft = async () => {
|
||||||
|
const meta = (await fetch(
|
||||||
|
'https://meta.polymc.org/v1/net.minecraft/index.json'
|
||||||
|
).then((r) => r.json())) as { versions: SimplifiedMetaVersion[] };
|
||||||
|
|
||||||
|
return meta.versions.filter((v) => v.recommended)[0].version;
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue