This repository has been 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
Labels
bug
Something isn't working
Just results in a bunch of error logs:
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
The text was updated successfully, but these errors were encountered: