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.')
评论列表
文章目录