Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

A notification can never be sent if the subscriber's channel has since been deleted #5

@connorkuehl

Description

@connorkuehl

Just results in a bunch of error logs:

2023/08/02 11:14:45 [ERROR] session.ChannelMessageSend: HTTP 404 Not Found, {"message": "Unknown Channel", "code": 10003}

Could use errors.As with a *discordgo.RESTError[1], then check if restErr.Message != nil && restErr.Message.Code == discordgo.ErrCodeUnknownChannel[2] to detect the error condition for trying to send a message to a channel that no longer exists.

Probably simplest to just delete the subscription with subscriptions.Delete(n.SubscriptionID). An easy efficiency win to avoid spurious extra deletes would be to just track which subscriptions have been deleted as part of this process during bot.Update and then just skip over any notifications corresponding to those IDs.

[1] https://pkg.go.dev/github.com/bwmarrin/discordgo#RESTError
[2] https://pkg.go.dev/github.com/bwmarrin/discordgo#ErrCodeUnknownChannel

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions