Skip to content

Instantly share code, notes, and snippets.

View Trao-X's full-sized avatar

TraoX_ Trao-X

View GitHub Profile
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])