reddit.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:dogbot 作者: slice 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号