Skip to content

Commit 4cb0065

Browse files
committed
hotfix: handle deleted feed channels in a hacky way
1 parent 4091546 commit 4cb0065

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cogs/backend/workers/release_feed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async def send_to_rfi(self,
118118
session=self.bot.session)
119119
await webhook.send(text, embed=embed, username=self.bot.user.name, avatar_url=self.bot.user.avatar.url)
120120
except (discord.errors.NotFound, discord.errors.Forbidden, discord.errors.HTTPException):
121-
await self.bot.db.guilds.find_one_and_delete({'_id': guild['_id']})
121+
await self.bot.db.guilds.update_one({'_id': guild['_id']}, {'$pull': {'feed': {'hook': rfi['hook']}}})
122122
return False
123123
return True
124124

cogs/ecosystem/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ def __init__(self, bot: GitBot):
2121
}
2222

2323
@staticmethod
24-
def construct_release_feed_list(ctx: GitBotContext, rf: ReleaseFeed) -> str:
24+
async def construct_release_feed_list(ctx: GitBotContext, rf: ReleaseFeed) -> str:
2525
item: str = '' if rf else ctx.l.generic.nonexistent.release_feed
2626
for rfi in rf:
27+
if rfi['cid'] not in map(lambda c: c.id, ctx.guild.channels):
28+
await ctx.bot.db.guilds.update_one({'_id': ctx.guild.id},
29+
{'$pull': {'feed': {'cid': rfi['cid']}}})
30+
ctx.bot.logger.debug('Removed channel %d from feed in GID %d', rfi['cid'], ctx.guild.id)
31+
continue
2732
m: str = '' if not rfi.get('mention') else ' - ' + ctx.bot.mgr.release_feed_mention_to_actual(rfi['mention'])
2833
item += ctx.bot.mgr.e.square + ' ' + f'<#{rfi["cid"]}>{m}\n' + \
2934
('\n'.join([f'⠀⠀- [`{rfr["name"]}`](https://github.com/{rfr["name"]})'
@@ -118,7 +123,7 @@ async def config_show_feed_command(self, ctx: GitBotContext):
118123
embed: GitBotEmbed = GitBotEmbed(
119124
color=self.bot.mgr.c.discord.blurple,
120125
title=f"{self.bot.mgr.e.github} {ctx.l.config.show.feed.title}",
121-
description=self.construct_release_feed_list(ctx, guild['feed']),
126+
description=await self.construct_release_feed_list(ctx, guild['feed']),
122127
footer=ctx.fmt('footer', f'git config feed channel {{{ctx.l.help.argument_explainers.channel.name}}}'))
123128
await embed.send(ctx)
124129
else:

0 commit comments

Comments
 (0)