get_member_named()缺少1个必需的位置参数:“名称”

时间:2018-07-22 12:14:28

标签: python discord.py

@my_bot.event
async def on_message(message):
    if message.content.startswith('!test'):
        server = discord.Server
        await my_bot.send_message(server.get_member_named('mystery#5137'), 'Hello')

为什么不起作用?

错误:

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\Roman-PC\AppData\Local\Programs\Python\Python36-32\lib\discord\client.py", line 307, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "C:/Users/Roman-PC/Desktop/t1.py", line 11, in on_message
    await my_bot.send_message(server.get_member_named('name'), 'Hello')
TypeError: get_member_named() missing 1 required positional argument: 'name'

2 个答案:

答案 0 :(得分:0)

您不应创建discord.Server,而应从message对象获得服务器(请参见docs中的discord.Message

s = message.server

那么您可以

s.get_member_named('mystery#5137')

答案 1 :(得分:0)

您需要使用名称定义成员。 而不是:

server = discord.Server
await my_bot.send_message(server.get_member_named('mystery#5137'), 'Hello')

您需要:

server = message.server
await my_bot.send_message(server.get_member_named(name='mystery#5137'), 'Hello')