Code Monkey home page Code Monkey logo

Comments (10)

lovvskillz avatar lovvskillz commented on May 18, 2024 4

I think I will change that later today or tomorrow and also provide a release.

from python-discord-webhook.

BarryThrill avatar BarryThrill commented on May 18, 2024 1

Actually, there should always be a list returned. No matter if only one webhook URL was given or several.
However, when I think about it, it would be better to just return the response directly if only one URL is given.

Thay would make sense I guess. Im pretty sure that is the way it supposed to do. If more than one webhook URL then return the response in the list but if only one then no need to be in a list. The bug is that it sometimes returns in list using only one webhook.

from python-discord-webhook.

outfielder avatar outfielder commented on May 18, 2024

but lately I did find out that it sometimes returns as:
[<Response [200]>]

Could you please add more detail about the times that you get the response object in a list and the times you do not? Are you sending the same type of webhook each time (i.e webhooks with similar embedded information) or are you sending different types of webhooks?

from python-discord-webhook.

BarryThrill avatar BarryThrill commented on May 18, 2024

but lately I did find out that it sometimes returns as:
[<Response [200]>]

Could you please add more detail about the times that you get the response object in a list and the times you do not? Are you sending the same type of webhook each time (i.e webhooks with similar embedded information) or are you sending different types of webhooks?

Hello! Sorry for the delay.

The situation that happens is abit hard for me to know exactly the reason why it happens but I did come up with a small "hotfix"

response = webhook.execute()

if isinstance(response, List):
    assert(len(response) == 1)
    response = response[0]

if response.ok:
    print("YAY")
    return

However the details I have is that currently I am not using the multi-webhook function you have created due to those are not in thread. Meaning if one webhook fails or hits the rate-limit. It will stop the second one to send until the first webhook is done. So what I do is that I put each webhook URL to a thread to send to response = webhook.execute() but each webhook URL is different but the webhook embed is the same. Example here:

webhook_dict = {
    "key1": "https://discord.....",
   "key2": "https://discord....."
}

for key, discord_webhook_url in webhook_dict.items():
	webhook = DiscordWebhook(
		url=discord_webhook_url,
		username="Test"
	)

	webhook.add_embed(embed)

	Thread(
		target=post_embed,
		args=(
			webhook
		)
	).start()

return


def post_embed(webhook):
    while True:
        try:

            response = webhook.execute()

            if isinstance(response, List):
                assert(len(response) == 1)
                response = response[0]

            if response.ok:
                logger.info("Succesfully sent to Discord")
                return
				
			else:
			   # Handling 429 etc etc...

from python-discord-webhook.

outfielder avatar outfielder commented on May 18, 2024

I believe I have managed to replicate your issue where the response for one object is sometimes returned as a list and sometimes not, but as you have previously mentioned it does seem to be random.

Have you since found any pattern to when the response may be returned as a list?

from python-discord-webhook.

lovvskillz avatar lovvskillz commented on May 18, 2024

Actually, there should always be a list returned. No matter if only one webhook URL was given or several.
However, when I think about it, it would be better to just return the response directly if only one URL is given.

from python-discord-webhook.

BarryThrill avatar BarryThrill commented on May 18, 2024

I believe I have managed to replicate your issue where the response for one object is sometimes returned as a list and sometimes not, but as you have previously mentioned it does seem to be random.

Have you since found any pattern to when the response may be returned as a list?

Hey! I did not found any pattern yet of why it does it. It seems super random which is really odd. Im not sure if its Discord themselves that returns it like that nor this package but I believe it wasn't like this before the latest update but I might be wrong as well :)

from python-discord-webhook.

BarryThrill avatar BarryThrill commented on May 18, 2024

I think I will change that later today or tomorrow and also provide a release.

Looking forward!

from python-discord-webhook.

lovvskillz avatar lovvskillz commented on May 18, 2024

This should be fixed in the version 0.12.0.
Let me know if it worked out for you.

from python-discord-webhook.

BarryThrill avatar BarryThrill commented on May 18, 2024

This should be fixed in the version 0.12.0.
Let me know if it worked out for you.

Will do! By looking at the code, I do see that it should work fine since its similar code as I use today 😁

from python-discord-webhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.