MissingRequiredArgument:上下文是缺少的必需参数
MissingRequiredArgument: context is a required argument that is missing
我还是新手(因为我休息了一下,几乎忘记了一切)。我正在编写一个 AFK 机器人,这发生了......
错误:MissingRequiredArgument: context is a required argument that is missing.
代码:
@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
请帮忙。
删除上下文参数并将代码中的任何 context
部分替换为 ctx。 ctx 已经是上下文。
例如
name = ctx.author.display_name
author = ctx.author
guild = ctx.guild
我还是新手(因为我休息了一下,几乎忘记了一切)。我正在编写一个 AFK 机器人,这发生了......
错误:MissingRequiredArgument: context is a required argument that is missing.
代码:
@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
请帮忙。
删除上下文参数并将代码中的任何 context
部分替换为 ctx。 ctx 已经是上下文。
例如
name = ctx.author.display_name
author = ctx.author
guild = ctx.guild