Discord API、get_member(user_id) 错误

Discord API, get_member(user_id) errors

我有这段代码,我很好奇为什么它不起作用。问题出在 k = discord.Server.get_member(j) 它说

"TypeError: get_member() missing 1 required positional argument: 'user_id'".

此代码使用 discord.py:

@client.event
async def on_message(message):
if message.content.startswith('/sendpm'):
    print(message.author)
    j = message.content.replace('/sendpm ', '')
    print(j)
    j = j.replace('@', '')
    j = j.replace('<', '')
    j = j.replace('>', '')
    j = j.replace('!', '')
    print(l)
    k = discord.Server.get_member(j) #problem is here
    await client.send_message(await client.start_private_message(k), spammsg)
    await client.send_message(message.channel, 'sent' + message.author.mention)

此代码正在访问 discord.Server 的方法,就好像它是静态方法一样:

k = discord.Server.get_member(j)

函数get_member is defined as:

def get_member(self, user_id):

它接受 self 作为第一个参数,因为它是要在实例上调用的,例如:

server = discord.Server()
server.get_member(user_id)

我不知道这是否是获取 Server 实例的正确方法。 This example 似乎有不同的方法来访问服务器实例:

@client.event
async def on_member_join(member):
    server = member.server
    fmt = 'Welcome {0.mention} to {1.name}!'
    await client.send_message(server, fmt.format(member, server))