Comments (10)
I think I will change that later today or tomorrow and also provide a release.
from python-discord-webhook.
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.
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.
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.
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.
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.
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.
I think I will change that later today or tomorrow and also provide a release.
Looking forward!
from python-discord-webhook.
This should be fixed in the version 0.12.0
.
Let me know if it worked out for you.
from python-discord-webhook.
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)
- raise InvalidSchema(f"No connection adapters were found for {url!r}") HOT 1
- [1/1] Webhook status code 400: {"embeds": ["0"]} whenever I'm trying to add a longer url to the webhook's embed.
- Add `thread_id` support
- TypeError: Object of type Embed is not JSON serializable HOT 2
- Multiple webhook URLs not working in v1.0.0 HOT 2
- Can't remove files when using webhook.edit() HOT 2
- Timezone for set_timestamp() HOT 1
- Add donation link or GitHub Sponsors
- Add better support for sending several images HOT 2
- Add a parameter to delete a message by id, webhook.delete() method HOT 1
- Image not loading in Discord
- JSON Decode Error when executing webhook HOT 3
- Hits rate limit and got me blocked temporarily
- Using timeout param > 1 on Webhook causes 400 HOT 1
- Webhook status code 400 HOT 2
- Object of type DiscordComponentButton is not JSON serializable HOT 1
- Feature DiscordEmbed.from_dict(embed_json)
- Allowed mentions now expects a dictionary and not a list HOT 1
- feature request: search for threads
- Avatar Url not showing in create_batch call
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-discord-webhook.