我一直在研究用 python 编码的不和谐机器人。当用户加入服务器并离开服务器时,我一直试图让我的机器人说出一条消息。但是当我测试它时,我得到了 2 个错误,我不明白这些错误。而且我不确定我做错了什么。如果有人可以帮助解释这些错误,并为我的代码指出正确的方向,我将不胜感激。
我研究了discord rewrite api,并与朋友在我的服务器中对其进行了测试,当时我遇到了错误
@client.event
async def on_member_join(member):
channel = member.server.get_channel("499457708978864151")
msg = 'Welcome to the {1.name} Server, {0.mention}'
await client.say(channel, msg.format(member, member.server))
@client.event
async def on_member_remove(member):
channel = member.server.get_channel("499457708978864151")
msg = '{0.mention} has left the server'
await client.say((channel, msg.format(member, member.server)))
我希望我的机器人在他们进入服务器时说欢迎使用(服务器的名称)服务器,@username,当用户离开时@username 已经离开服务器,但我收到了这些错误:
TypeError: send_message() takes from 2 to 3 positional arguments but 4 were given
discord.errors.InvalidArgument: Destination must be Channel, PrivateChannel, User, or Object. Received NoneType
这是我的完整追溯
Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Users\Chris\PycharmProjects\untitled1\venv\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:/Users/Chris/PycharmProjects/untitled1/RomaniBot.py", line 37, in on_member_join
await client.say(channel, msg.format(member, member.server))
File "C:\Users\Chris\PycharmProjects\untitled1\venv\lib\site-packages\discord\ext\commands\bot.py", line 350, in say
coro = self.send_message(destination, *args, **kwargs)
TypeError: send_message() takes from 2 to 3 positional arguments but 4 were given
Ignoring exception in on_member_remove
Traceback (most recent call last):
慕无忌1623718
慕雪6442864
相关分类