def feeds_delete(self, ctx, *, feed: str):
"""Removes a feed from the channel.
This will also delete the associated role so this
action is irreversible.
"""
query = 'DELETE FROM feeds WHERE channel_id=$1 AND name=$2 RETURNING *;'
records = await ctx.db.fetch(query, ctx.channel.id, feed)
self.get_feeds.invalidate(self, ctx.channel.id)
if len(records) == 0:
return await ctx.send('This feed does not exist.')
for record in records:
role = discord.utils.find(lambda r: r.id == record['role_id'], ctx.guild.roles)
if role is not None:
try:
await role.delete()
except discord.HTTPException:
continue
await ctx.send(f'{ctx.tick(True)} Removed feed.')
评论列表
文章目录