1

I've recently tried doing some image generating with craiyon's API, and send the image through discord.py, But i realized that it takes a long time and it would stop the entire bot from working all together. I tried to implement multithreading, but i had no way to send the image back inside of the class i instance using threading.Thread()

Code:

class message_del:
    def __init__(self, message):
        self._message = message
        t = threading.Thread(target=self.images)
        t.start()

    def images(self):
        if self._message.content == "$image":
            generator = Craiyon()
            result = generator.generate(self._message.content)
            result.save_images()
            self._message.reply(file=discord.File("generated//image-1.jpg"))

@client.event
async def on_message(message):
    message_del(message)

with it i get this error: RuntimeWarning: Enable tracemalloc to get the object allocation traceback please help

I tried adding async and await to the class, but __init__ doesn't return take async then i tried ditching all of this and creating the image then sending it through another function, but that didn't work cuz of the async stuff. So i got stuck.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.