Skip to content

Replace get_channel by fetch_channel after d.py update in on_ready event listeners. #380

@SebastiaanZ

Description

@SebastiaanZ

Some of our cogs use the on_ready event to load the destination channel for the messages they relay or post. However, occasionally, the internal channel cache used by the get_channel method isn't ready at that point, resulting in the channel not being loaded and the Cog not working:

22608 | Jul 02 13:52:07 pd.beardfist.com Bot: |                bot.cogs.reddit |  WARNING | Couldn't locate a channel for subreddit relaying.

While this example is from the Reddit cog, the same thing happens intermittently with the bigbrother Cog as well. I've already added retry logic to the bigbrother cog in the Django rewrite, but a better solution would be to replace these get_channel methods by fetch_channel coroutines after we upgrade our discord.py version.

This will fetch the channels from the API, bypassing the problem with the internal channel cache entirely. It also has retry logic built-in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t: bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions