refactor: move latest version logic

This commit is contained in:
Sefa Eyeoglu 2022-06-14 12:37:51 +02:00
parent e1622eb545
commit b5abe4e416
No known key found for this signature in database
GPG key ID: C10411294912A422
5 changed files with 30 additions and 30 deletions

View file

@ -22,7 +22,7 @@ import { join } from 'path';
import { green, bold, blue, underline, yellow } from 'kleur/colors';
import 'dotenv/config';
import { getLatestMinecraft } from './utils/minecraftVersion';
import { getLatestMinecraftVersion } from './utils/remoteVersions';
export interface Command {
name: string;
@ -79,7 +79,7 @@ client.once('ready', async () => {
);
client.user?.presence.set({
activities: [{ name: `Minecraft ${await getLatestMinecraft()}` }],
activities: [{ name: `Minecraft ${await getLatestMinecraftVersion()}` }],
status: 'online',
});
@ -133,6 +133,7 @@ async function parseMsg(e: Message) {
);
if (!cmd) {
// TODO: Do not read tags.json everytime there is a new message
const tag = await getTags().then((r) =>
r.find(
(t) => t.name == parsed.command || t.aliases?.includes(parsed.command)
@ -142,12 +143,11 @@ async function parseMsg(e: Message) {
if (tag) {
if (tag.text) {
e.reply(tag.text);
return true;
} else if (tag.embed) {
const em = new MessageEmbed(tag.embed);
e.reply({ embeds: [em] });
return true;
}
return true;
}
return false;
}