def watch(self, ctx, channel: discord.TextChannel, subreddit: str):
"""
Sets up a channel for me to forward hot posts to, from a subreddit of your choosing.
Only Dogbot Moderators may use this command.
"""
# check that there isn't too many feeds
async with self.bot.pgpool.acquire() as conn:
count = (await conn.fetchrow('SELECT COUNT(*) FROM reddit_feeds WHERE guild_id = $1', ctx.guild.id))['count']
logger.debug('Guild %s (%d) has %d feeds', ctx.guild.name, ctx.guild.id, count)
if count >= 2:
# they have 2 feeds, which is the max
return await ctx.send(
f'You have too many feeds! You can only have two at a time. Use `{ctx.prefix}reddit feeds` '
'check the feeds in this server.'
)
await conn.execute('INSERT INTO reddit_feeds VALUES ($1, $2, $3)', ctx.guild.id, channel.id, subreddit)
await ctx.ok()
评论列表
文章目录