0

I have written a discord.py bot on repl.it that makes one able to quote on text. i will spare you on the code for this one, since it does not help in answerign the question, but basically, it splits a send message with a parameter and puts these splits into an embed. To make the channel look clean, the bot then deletes the original message.

As an update for my bot I want to implement qoting images, as they don't require writing that much. This is where i ran into a problem:
original message

Using the prefix 'dq' i can attach an image and write a context for the image seperated with a space. It outputs the following:
output

It might seem fine now, but after an hour or two, the image is either gone or loading forever: loading forever

(This is a previous example, the text doesn't match)

I know that this is because the original message is being deleted by the bot. The Bot grabs the attachment URL and repost it:

# checking for the prefix
if message.content.startswith("dq "):

   # delete original message
        await message.delete()

   # split the message with a parameter
        quot = message.content.split("//")

      # the sent messages get dived by length of quot, that equals the amount of arguments given
        if len(quot) == 1:

         # 1st argument taken from message
            context = quot[0]

         # attachment taken from message
            urll = message.attachments[0].url

         # message context gets split to delte the prefix 'dq'
            text = context.split()
            text.pop(0)

         # text being put together with discord text style
            context = "*"+" ".join(text)+"*\n"



         

   # creates an embed with the content above
        embeda = discord.Embed(title=context, color=0xffffff)
           embeda.set_image(url=urll)
           embeda.set_footer(text="("+message.author.name+")")

What i am getting at in this horrobly long description: i need a way to delete the images from the original message, but i need them to stay in the message the bot sent.

It would be nice to get some quick advice on this problem!

1 Answers1

0

This happens because you are deleting the message the image is sent in. Discord sees the relevant message is gone and removes the file from its servers to save space.

You need to save the image either locally or in memory then upload it to either discord's CDN or a third party CDN and refer to it in your embed.

Talpa
  • 66
  • 3