维基百科命令Discord.py

2024-06-16 13:59:14 发布

您现在位置:Python中文网/ 问答频道 /正文

@commands.command()
@commands.cooldown(1,10,BucketType.user)
async def wiki(self,ctx,*,word):
    def sum(arg):
        definition = wikipedia.summary(arg,sentences=3,chars=1000)
        return sum(word)
    await ctx.send(sum)

我正在生成一个Wiki命令,它无法按预期工作,并以以下方式响应:

Bot Response


Tags: selfasyncdefwikiargwikipediacommandcommands
1条回答
网友
1楼 · 发布于 2024-06-16 13:59:14

那是因为你用错了sum。与此相反:

await ctx.send(sum)

你必须这样做:

await ctx.send(sum(word))

还有,为什么要从函数本身调用函数?在sum中,您应该返回definition

尽量不要隐藏内置的sum。您应该将函数重命名为get_definition或其他名称

相关问题 更多 >