He estado usando este script aquí https://github.com/17teen/Discord-Image-Scraper , pero me topé con un problema en el que extrae un solo mensaje que contiene, por ejemplo, 5 archivos adjuntos y los lleva a la matriz JSON como un todo. en lugar de separarlos en enlaces individuales como si fuera una imagen por mensaje.
Intenté usar .replace(',','') y .join(',') tanto en post.js como en scraper.js y todavía me enfrento a este problema.
[ "https://media.discordapp.net/attachments/831804312538841088/893067795154231337/IMG_20210930_113200.jpg,https://media.discordapp.net/attachments/831804312538841088/893067795322011668/IMG_20210930_113039.jpg,https://media.discordapp.net/attachments/831804312538841088/893067795535900702/IMG_20210930_112940.jpg,https://media.discordapp.net/attachments/831804312538841088/893067795741437952/IMG_20210930_113006.jpg","EXTRA","EXTRA" ]Gracias a @MrMythical por la solución al problema.
Para cualquiera que use este código, la solución está a continuación:
El código original era
webhookCli.send(link.split(",")).then((msg) => { spinner.succeed(greenBright(`[${index}] Link Posted: ${yellowBright(msg.content)}`)) }).catch((err) => { spinner.fail(red(`[${index}] Link failed to post | ${err}`)) }) CÓDIGO MEJORADO Solución agregada para link
// Settings const { webHook_id, webHook_token } = require("./settings.json"); const { greenBright, red, grey, yellowBright } = require("chalk"); const ora = require("ora"); const readline = require("readline").createInterface({ input: process.stdin, output: process.stdout }); // Modules const { WebhookClient } = require("discord.js"); // Webhook const webhookCli = new WebhookClient(webHook_id, webHook_token); readline.question(grey("[?] Do you wish to post these links? (Y/N) "), (answr) => { if (answr === "Y" || answr === "y" || answr === "Yes" || answr === "yes" || answr === "YES") return Post() if (answr === "N" || answr === "n" || answr === "No" || answr === "no" || answr === "NO") return process.exit(1); }); /** * Posts links to a specifed channel */ function Post() { const spinner = ora("Preparing to post").start(); const fetchLinks = require("./links.json") fetchLinks.forEach((link, index) => { webhookCli.send(link.split(",")).then((msg) => { spinner.succeed(greenBright(`[${index}] Link Posted: ${yellowBright(msg.content)}`)) }).catch((err) => { spinner.fail(red(`[${index}] Link failed to post | ${err}`)) }) }); }