tags.py 文件源码

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

项目:PyMiki 作者: TheGrammarJew 项目源码 文件源码
def search(self, ctx, *, query: commands.clean_content):
        """Searches for a tag.

        The query must be at least 3 characters.
        """

        if len(query) < 3:
            return await ctx.send('The query length must be at least three characters.')

        sql = """SELECT name
                 FROM tag_lookup
                 WHERE location_id=$1 AND name % $2
                 ORDER BY similarity(name, $2) DESC
                 LIMIT 100;
              """

        results = await ctx.db.fetch(sql, ctx.guild.id, query)

        if results:
            try:
                p = Pages(ctx, entries=tuple(r[0] for r in results), per_page=20)
            except Exception as e:
                await ctx.send(e)
            else:
                await ctx.release()
                await p.paginate()
        else:
            await ctx.send('No tags found.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号