Currently, our bot seems to be able to display the generated image on Discord as can be seen:
However, on the background I save each image in memory first and then send to the Discord.
images = re.search('\[(.*)\]', req.content.decode("utf-8") ).group(0)
encodings = [e.replace("\\n", "") for e in re.findall('"([^"]*)"', images)]
for encoded in encodings:
with open("image.png", "wb") as fh:
fh.write(b64decode(encoded)) # get rid of this
await message.channel.send(file = discord.File("image.png"))
This approach is not favorable given the fact that it requires lots of I/O operations.
[ ] Find a way to send the image to Discord without saving it in local.
Sometimes it's not able to display the image and sends a meaningless file whose size is 0 KB.
Solved the second problem with this commit. Most probably, it was due to the fact that I was trying to send the image to Discord in the with block immediately after the writing operation.
Currently, our bot seems to be able to display the generated image on Discord as can be seen:
However, on the background I save each image in memory first and then send to the Discord.
This approach is not favorable given the fact that it requires lots of I/O operations.
Sometimes it's not able to display the image and sends a meaningless file whose size is 0 KB.