我不断收到命令引发异常:TypeError:send()接受1到2个位置参数,但给出了3个
我如何修理dis
limit = 500
@bot.command()
async def rule34(ctx, *, tags:str):
"""Searches rule34.xxx for the specified tagged images"""
await ctx.channel.trigger_typing()
tags = strip_global_mentions(tags, ctx)
try:
data = requests.get("http://rule34.xxx/index.php?page=dapi&s=post&q=index&json=1&limit={}&tags={}".format(limit, tags), headers=header).json()
except json.JSONDecodeError:
await ctx.send("nothing found chief")
return
count = len(data)
if count == 0:
await ctx.send("nothing found cheif")
return
image_count = 4
if count < 4:
image_count = count
images = []
for i in range(image_count):
image = data[random.randint(0, count)]
images.append("http://img.rule34.xxx/images/{}/{}".format(image["directory"], image["image"]))
await ctx.send("nsfw.results", ctx).format(image_count, count, tags, "\n".join(images))
据我所知,您只是试图发送一条格式良好的消息,其中包含所有变量,因此这方面的一个示例解决方案可能是:
与原来的最后一行相比已修复的问题:
ctx
参数nsfw.results
字符串更改为可以格式化的字符串有用链接: Python string.format() documentationDedicated Pyformat site
相关问题 更多 >
编程相关推荐