mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 01:05:58 +02:00
build: attempt to restore Netlify build preview
This commit is contained in:
+38
-34
@@ -6,41 +6,45 @@ const Discord = require("discord.js")
|
|||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const { Readable } = require("stream")
|
const { Readable } = require("stream")
|
||||||
|
|
||||||
const client = new Discord.Client()
|
function execute() {
|
||||||
|
const client = new Discord.Client()
|
||||||
|
|
||||||
const { BOT_TOKEN } = process.env
|
const { BOT_TOKEN } = process.env
|
||||||
const TPH = "244230771232079873"
|
const TPH = "244230771232079873"
|
||||||
const DESTINATION = "./users.json"
|
const DESTINATION = "./users.json"
|
||||||
|
|
||||||
if (!BOT_TOKEN) {
|
const writeS = (content, dest) => {
|
||||||
throw Error("Missing BOT_TOKEN environment variable")
|
const source = new Readable()
|
||||||
}
|
source.push(JSON.stringify(content))
|
||||||
|
source.push(null)
|
||||||
const writeS = (content, dest) => {
|
return source.pipe(dest)
|
||||||
const source = new Readable()
|
|
||||||
source.push(JSON.stringify(content))
|
|
||||||
source.push(null)
|
|
||||||
return source.pipe(dest)
|
|
||||||
}
|
|
||||||
|
|
||||||
client.once("ready", async () => {
|
|
||||||
console.log("Bot ready, fetching user list...")
|
|
||||||
const tph = client.guilds.cache.get(TPH)
|
|
||||||
if (!tph) {
|
|
||||||
throw Error("Bot is not in TPH, cannot fetch users")
|
|
||||||
}
|
}
|
||||||
const members = await tph.members.fetch()
|
|
||||||
const memberInfo = members.map((member) => ({
|
|
||||||
avatar: member.user.displayAvatarURL(),
|
|
||||||
identifier: member.user.tag,
|
|
||||||
}))
|
|
||||||
const wrs = fs.createWriteStream(DESTINATION)
|
|
||||||
console.log(`Fetched ${memberInfo.length} users, writing to ${DESTINATION}`)
|
|
||||||
writeS(memberInfo, wrs).on("finish", () => {
|
|
||||||
console.log("Finished writing list")
|
|
||||||
process.exit(0)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log("Attempting to log in...")
|
client.once("ready", async () => {
|
||||||
client.login(BOT_TOKEN)
|
console.log("Bot ready, fetching user list...")
|
||||||
|
const tph = client.guilds.cache.get(TPH)
|
||||||
|
if (!tph) {
|
||||||
|
throw Error("Bot is not in TPH, cannot fetch users")
|
||||||
|
}
|
||||||
|
const members = await tph.members.fetch()
|
||||||
|
const memberInfo = members.map((member) => ({
|
||||||
|
avatar: member.user.displayAvatarURL(),
|
||||||
|
identifier: member.user.tag,
|
||||||
|
}))
|
||||||
|
const wrs = fs.createWriteStream(DESTINATION)
|
||||||
|
console.log(`Fetched ${memberInfo.length} users, writing to ${DESTINATION}`)
|
||||||
|
writeS(memberInfo, wrs).on("finish", () => {
|
||||||
|
console.log("Finished writing list")
|
||||||
|
process.exit(0)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log("Attempting to log in...")
|
||||||
|
client.login(BOT_TOKEN)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.env.BOT_TOKEN) {
|
||||||
|
execute()
|
||||||
|
} else {
|
||||||
|
console.log("BOT_TOKEN missing, skipping.")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user