首页 > 解决方案 > discord.ext.commands.errors.CommandInvokeError:TypeError: open() 接受 1 个位置参数,但给出了 2 个

问题描述

我正在尝试建立 discord.py 经济,这是代码

async def get_bank_data():
        with open(bandata, "r") as f:
            users = json.load(f)
        return users

但是它返回“discord.ext.commands.errors.CommandInvokeError:命令引发异常:TypeError:open()需要1个位置参数但给出了2个”,有什么办法解决吗?

标签: pythondiscord.pydiscord.py-rewrite

解决方案


简单命令的示例可以解决您的问题:

@discord.ext.commands.command()
async def ping(ctx: discord.ext.commands.Context):
    await ctx.send('pong')

推荐阅读