import {Client, GatewayIntentBits} from "discord.js"; import * as dotenv from 'dotenv' dotenv.config(); const client = new Client({intents: [GatewayIntentBits.Guilds, GatewayIntentBits.MessageContent]}); let url = "https://ludwig.gg/_next/data/WuMIXOIMzuk5kVn73Mb02/all.json"; client.once("ready", () => { console.log("Ready!"); client.channels.cache.get("833901685054242849").send("Bot is online!"); }); client.on("messageCreate", async (message) => { if (message.content === "!change-url") { url = message.content.split(" ")[1]; message.channel.send("Changed url to " + url); } }) async function checkMogulMoves() { console.log("checking mogul moves") const page = await fetch(url).then(res => res.json()); if (page.pageProps.products === undefined) { client.channels.cache.get("833901685054242849").send("<@218072060923084802> Mogul Moves is down! CHANGE LINK"); } for (let product of page.pageProps.products) { if (product.name === "Boxing Club Hoodie") { for (let variant of product.variants) { if (variant.attributesDescription === "M") { if (variant.status !== "UNAVAILABLE") { client.channels.cache.get("833901685054242849").send("<@218072060923084802> Boxing Club Hoodie is in stock!"); } } } } else if (product.name === "Chess Club Hoodie") { for (let variant of product.variants) { if (variant.attributesDescription === "M") { if (variant.status !== "UNAVAILABLE") { client.channels.cache.get("833901685054242849").send("<@218072060923084802> Chess Club Hoodie is in stock!"); } } } } } } setInterval(checkMogulMoves, 100000); await client.login(process.env.DISCORD_TOKEN);