python-discord-webhook icon indicating copy to clipboard operation
python-discord-webhook copied to clipboard

How can I get the thread ID of a newly created thread?

Open kass507 opened this issue 1 year ago • 0 comments

I am creating a thread and intend to send several responses to that newly created thread.

But I can't get the thread ID, even though the code successfully creates the thread.

Is there something I'm doing wrong? Or is it an unavailable function?

def discord(media_path, name):
    body = "Puedes apoyarme"
    try:
        webhook = DiscordWebhook(url=config['discord']['webhook_thread'], content=body, thread_name=f"Pestañas de la Tienda del dia: {kasstime}")
        temp_image_path = f"{name}_discord_resized.jpg"
        resize_image_discord(media_path, temp_image_path)

        with open(temp_image_path, "rb") as shopImage:
            webhook.add_file(file=shopImage.read(), filename='tienda.jpg')

        response = webhook.execute()
        print("Enviado con Éxito a Discord")
        print(webhook)
        print(webhook.thread_id)
        return webhook.thread_id
    except Exception as e:
        print(f"Error al enviar la tienda de objetos a Discord, {e}")
        return None
Enviado con Éxito a Discord
<discord_webhook.webhook.DiscordWebhook object at 0x106d9b500>
None

kass507 avatar Jun 23 '24 22:06 kass507