Discord.js使用新链接重新发布嵌入的图像

时间:2020-06-23 09:04:12

标签: javascript image bots discord discord.js

我需要一种重新上传不和谐嵌入图像的方法,以将其自己发布为缩略图。我想删除原始漫游器的消息,而将我的消息用作派生消息,这有点像“短模式”。问题是,当我删除原始帖子时,该图像也会丢失,并且我的短模式重新发布不会加载该图像。我也尝试添加延迟,但这并不理想,看起来有点难看。如何获取不和谐的嵌入图像,下载并重新将同一图像作为缩略图上传?这是完整的代码,但是我将编辑一些不相关的信息:

    if (message.author.id == botid && message.guild.id == guild2) {
      message.embeds.forEach((e) => {
        if (e.title !== undefined && e.title.startsWith("The Dungeon")) {
          if (e.image) {

            let url = e.image.url;
            let desc = e.description;
            request(url, async function(err, res, body) {
              if (err !== null) return;
            
              imghash
                .hash(body)
               .then(async (hash) => {
                  let rareresult = raresdb[hash];
                  let notify = notifydb[message.guild.id];
                  if (rareresult === undefined) {
                    let result = db[hash];
                    if (result === undefined) {
                      embed
                        .setTitle("What is this?")
                        .setThumbnail(url)
                        .setColor("0xE91447")")
                      console.log(something here);
                      client.log(something here);
                      return message.channel.send(embed)
                    }
                
                      const args = e.footer.text.split(' ');
                      const prefix = args[10].split('verse');
                      embed
                        .setTitle("You encountered a wild " + result + "!")
                        .setThumbnail(url)
                        .setDescription(desc)
                        .setFooter("Type "+ prefix[0] +"wish " + result + " to find! ")
                      message.channel.send(embed)
                      console.log(something here);
                      //await delay(777);
                     // message.delete(e)
                   return client.log(something here);
                  }
                  
                  if (notify === undefined) {
                      const args = e.footer.text.split(' ');
                      const prefix = args[10].split('verse');
                      embed
                        .setTitle("You spotted " + rareresult + "!")
                        .setThumbnail(url)
                        .setDescription(desc)
                        .setFooter("Type "+ prefix[0] +"wish " + rareresult + " to find!")
                      message.channel.send(embed)

                     // await delay(666);
                      //message.delete(e)
                    client.log(something here);
                    return console.log(something here);
                  };

                  message.channel.send(notify + "**" + rareresult + "** happened!");
                      const args = e.footer.text.split(' ');
                      const prefix = args[10].split('verse');
                      embed
                        .setTitle("You found " + rareresult + "!")
                        .setThumbnail(url)
                        .setDescription(desc)
                       .setFooter("Type "+ prefix[0] +"wish " + rareresult + " to find! ")
                      message.channel.send(embed)

                  let cnt = message.content
                    if (cnt !== " ") {
                    message.pin(0) // ?
                  }
                
                  client.log(something here);
                  console.log(something here);
                })
            });
          }
        }
      });
    }

鉴于我没有提供整个代码块,所以我之前的问题可能不清楚。但是重申一下,我想将e.image.url的{​​{1}}重新发布为我自己的.setThumbnail(url)的来源,而不是使用完全相同的来源,因为删除原始邮件时不会加载。那么如何使用url中完全相同的图像,而只是重新上传以使链接有所不同?

0 个答案:

没有答案