继续在我的discord bot cog中收到此错误 . 我在其他cogs中使用message.author就好了只是事件而不是命令 .

async def on_member_join(member):
    with open('profiles.json', 'r') as f:
        profiles = json.load(f)

    await update_profile(profiles, member)

    with open('profiles.json', 'w') as f:
            json.dump(profiles, f, indent=2)

@commands.command(name='my', pass_context=True)
async def my(self, ctx):

    with open('profiles.json', 'r') as x:
        profiles = json.load(x)

    await self.update_profile(profiles, ctx.message.author)

    with open('profiles.json', 'w') as x:
        json.dump(profiles, x, indent=2)


async def update_profile(self, user, message):
        profile_params = {'Xbox Live': 'xbl', 'PSN': 'psn', 'Steam ID': 'stm','Nintendo Friend Code': 'nfc'}
        msg = ctx.message
        bmsg = msg[4:7]
        emsg = msg[8:]
        if not user.name in users and not user.bot:
            do some stuff

这是我得到的错误我尝试了很多解决这个问题我找不到任何可以解决这个问题的东西

Traceback (most recent call last):
  File "C:\Users\Erik\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "D:\Discord Bot\profiles.py", line 28, in my
    await self.update_profile(profiles, ctx.message.author)
  File "D:\Discord Bot\profiles.py", line 36, in update_profile
    msg = ctx.message
NameError: name 'ctx' is not defined

我已经尝试了很多解决类似问题的工作 . 我注意到它在主py文件中工作正常,并且在on_message事件中的cog中也可以正常工作 . 当我在@ commands.command命令函数中使用它时它才起作用 .