Search code examples
pythondiscorddiscord.pymessage

MissingRequiredArgument: context is a required argument that is missing


Im Still New (Because I Took A Break And Forgot Almost Everything). I Was Coding An AFK Bot And This Happened...

Error: MissingRequiredArgument: context is a required argument that is missing.

Code:

@client.command()
async def start(ctx,context,user: discord.Member):
    def check(m):
        return m.author == ctx.author and m.channel == ctx.channel
    name = context.author.display_name
    author = context.author
    guild = context.guild
    AFKrole = discord.utils.get(guild.roles, name="AFK")
    if not AFKrole:
        AFKrole = await guild.create_role(name="AFK")
    await context.author.edit(nick=f"[AFK]{name}")
    await author.add_roles(AFKrole)
    await ctx.send(f"AFK Mode Started For **{author}**.")
    gt = await client.wait_for('message', check=check, timeout=180)
    if gt.content.lower() == "afk stop":
        await context.author.edit(nick=f"{name}")
        await author.remove_roles(AFKrole)
        await ctx.send(f"AFK Mode Stopped For **{author}**.")
    else:
        pass

please help.


Solution

  • Remove context parameter and replace any context part in the code with just ctx. ctx is already context.

    Ex.

    name = ctx.author.display_name
    author = ctx.author
    guild = ctx.guild