-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using one webhook returns as a list #43
Comments
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()
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 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... |
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? |
Actually, there should always be a list returned. No matter if only one webhook URL was given or several. |
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 :) |
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. |
I think I will change that later today or tomorrow and also provide a release. |
Looking forward! |
This should be fixed in the version |
Will do! By looking at the code, I do see that it should work fine since its similar code as I use today 😁 |
Hello guys!
Today I discovered that when I used one webhook, it sometimes returns as just one string etc if I do
as:
<Response [200]>
but lately I did find out that it sometimes returns as:
[<Response [200]>]
I assume this is sort of bug where it shouldn't mix between list and non-list when sending only using one webhook
This cause me an error where I cant use response.ok anymore since its inside a List but that shouldn't happen if im not using multiple webhooks url which I dont.
The text was updated successfully, but these errors were encountered: