Discord.py &引用;错误';自我';“未定义”;在member.edit中

Discord.py &引用;错误';自我';“未定义”;在member.edit中,discord.py,discord.py-rewrite,Discord.py,Discord.py Rewrite,我的代码有问题 discord.ext.commands.errors.CommandInvokeError:Command引发异常:TypeError:edit()缺少1个必需的位置参数:“self” 当我运行命令时。自我不应该被定义,对吗? 另外,当我添加self时,我会对ctx产生问题 守则: import discord from discord.ext import commands client = commands.Bot(command_prefix="/"

我的代码有问题

discord.ext.commands.errors.CommandInvokeError:Command引发异常:TypeError:edit()缺少1个必需的位置参数:“self”

当我运行命令时。自我不应该被定义,对吗? 另外,当我添加self时,我会对ctx产生问题

守则:

import discord
from discord.ext import commands


client = commands.Bot(command_prefix="/")


@client.command(pass_context=True)
async def join(ctx, member=discord.Member):
    channel = ctx.author.voice.channel
    await channel.connect()
    await member.edit(mute=True)


@client.command(pass_context=True)
async def leave(ctx):
    await ctx.voice_client.disconnect()


client.run("Token")

我设法找到了问题并解决了它

import discord
from discord.ext import commands


client = commands.Bot(command_prefix="/")


@client.command()
async def join(ctx):
    channel = ctx.author.voice.channel
    await channel.connect()
    await ctx.author.edit(mute=True)

@client.command()
async def leave(ctx):
    await ctx.voice_client.disconnect()


client.run("Token")
问题是,您在函数中包含了
成员
。如果希望它发送、编辑或处理消息作者,只需执行
ctx.author
,它将在消息作者身上设置。

您将变量“member”定义为类discord.member,而不是参数的tpy eof。您应该将
member=discord.member
更改为
member:discord.member