Skip to content

Commit

Permalink
prepare cache before starting
Browse files Browse the repository at this point in the history
  • Loading branch information
rtk-rnjn committed Sep 9, 2023
1 parent 729d901 commit de944cd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cogs/rss/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ def __init__(self, bot: Parrot) -> None:
def display_emoji(self) -> discord.PartialEmoji:
return discord.PartialEmoji(name="\N{SATELLITE}")

async def prepare_cache(self):
async for data in self.bot.guild_collections_ind.find():
for feed in data["rss"]:
channel = self.bot.get_channel(feed["channel_id"])
if not channel:
continue
webhook = discord.Webhook.from_url(feed["webhook_url"], session=self.bot.http_session)
self._cache[channel.id] = {"webhook": webhook, "link": feed["link"]}

async def cog_load(self) -> None:
await self.prepare_cache()
self.rss_loop.start()

async def cog_unload(self) -> None:
Expand Down

0 comments on commit de944cd

Please sign in to comment.