Skip to content

Retry sending a notification if you're being rate limited by Discord #61

Open
@fakeheal

Description

@fakeheal

Hi, all,

First of all great package, thank you!

I'm trying to channel all notifications in my application to our staff discord's channel. Sometimes we send many notifications at once to various text channels we end up being rate limited.

I saw a pull request that returns the underlying GuzzleHttp exception inCouldNotSendNotification. Our notifications are queued and sent "asynchronously", so I was thinking of releasing the job again after the seconds spcified in the response by Discord.

This is my code in theory, because I don't know how to test it without making real requests to Discord (test it in ci/cd pipelines):

public function failed(Exception $exception)
{
    if ($exception instanceof CouldNotSendNotification) {
        if ($exception->getCode() === 429) {
            $json = json_decode($exception->getPrevious()->getResponse());
            $this->release($json->retry_after);
        }
    }
}

Could you please advise on how to proceed?

Thank you,
Ivanka

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions