Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
Image Scraper pushing all attachments from single message to array

I've been using this script here https://github.com/17teen/Discord-Image-Scraper but stumbled on an issue where it scrapes from a single message that contains say 5 attachments and pulls them to the JSON array as a whole instead of separating them into individual links as if it was an image per message.

I've tried using .replace(',','') and .join(',') in both post.js and the scraper.js and still face this issue.

[
"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"
]
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Thanks to @MrMythical for the fix solution to the problem.

For anyone using this code, the fix is below:

The original code was

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}`)) 
})

IMPROVED CODE Added solution to 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}`)) })
    });
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda