Add Node packages for fetch/DOM

This commit is contained in:
James Shiffer
2024-02-06 23:23:26 +00:00
parent f3a71d6c27
commit 2bb82219ce
4 changed files with 524 additions and 42 deletions

View File

@@ -13,6 +13,8 @@ import {
TextChannel,
User
} from 'discord.js';
import fetch from 'node-fetch';
import { JSDOM } from 'jsdom';
import { logError, logInfo } from '../logging';
import {
db,
@@ -68,8 +70,8 @@ async function fetchMotd()
{
const res = await fetch(process.env.MOTD_HREF);
const xml = await res.text();
const parser = new DOMParser();
const doc = parser.parseFromString(xml, 'text/html');
const parser = new JSDOM(xml);
const doc = parser.window.document;
return doc.querySelector(process.env.MOTD_QUERY).textContent;
}