This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const prepareGuildContext = async (id) => { | |
let ctx = {isPublic: false} | |
try { | |
const resp = await fetch(`https://discord.com/servers/${id}`) | |
const html = await resp.text() | |
const isPublic = !/<title(?:.*?)>Page Not Found \| Discord<\/title>/g.test(html) | |
if(isPublic) { | |
const match = html.match(/<script(?: nonce=".*?")>window.__PRELOADED_STATE__ = ({.*?})(?:;?)<\/script>/) | |
if (match) { | |
const {serverPage: s} = JSON.parse(match[1]) |