Closed theAbdoSabbagh closed 2 years ago
That's the library's rate-limit handling handling the 429.
Avoid sending messages without abiding my slow mode because: a) This happens b) It's suspicious
Shouldn't there be something like a print statement that makes it clear for people or something? Also what's a proper way of achieving my goal if that's what the library is going to do?
I suggest you store your channels as a list of channel objects instead of a list of IDs which you fetch every time, maybe an option to raise_for_status in channel.send?
Shouldn't there be something like a print statement that makes it clear for people or something? Also what's a proper way of achieving my goal if that's what the library is going to do?
Putting a print statement in a library isn't proper. When a ratelimit is hit, it's logged.
The library is respecting what Discord asks it to do, and sleeps until the ratelimit passes before retrying sending the message.
If you want to avoid this, fetch the channel's message history, find your last message, and calculate the time passed to figure out when you can send a message next.
@Gltxched close the issue if there are no more questions please.
@dolfies why is this issue still open, it's usually common practice to close issues if there's nothing more to add. Comments can still be added to close issues, and reopened if it was closed by the author themselves.
Summary
So basically, if you try bot.fetch_channel() then try to send a message to that channel, WHILE from the client you can't send a message because of the cooldown, it's not gonna work, and it's not gonna raise an error
Reproduction Steps
I was trying to automate the process of sending messages to multiple channels, their IDs were stored as integers in a list. I looped over the list and tried fetching the channel and sending a message to it, and it happened that the first ID in the list was an ID of a channel that I had already sent a message to before, but I wanted to use it as a test, basically, if I put it in a try/except block, and I wanted to send a message to the channel, and print an error message if I faced an error, but it didn't even print, and the message was NOT sent. I removed it out of the try/except block, nothing changed, no error was raised. All the indentation was valid, I had no errors in the code and everything was defined as well.
Code
Expected Results
Send a message and if it failed, raise an exception.
Actual Results
Weirdly stops and doesn't raise an exception.
System Information
Checklist
Additional Information
No response