Skip to content
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

Open
connorkuehl opened this issue Aug 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@connorkuehl
Copy link
Owner

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

@connorkuehl connorkuehl added the bug Something isn't working label Aug 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant