Why am I getting TypeError: start_chat() missing 1 required positional argument: 'message'?
Why am I getting TypeError: start_chat() missing 1 required positional argument: 'message'?
我正在尝试为我的 Discord 聊天机器人创建主程序,但在尝试查看它是否运行时出现此错误:
Traceback (most recent call last):
File "C:\Users\amjad\OneDrive\Documents\Goldsmiths\Year 3\Final Year\Project\Test4\main.py", line 87, in <module>
DiscordChatbot.start_chat()
TypeError: start_chat() missing 1 required positional argument: 'message'
我的代码如下:
async def start_chat(self, message):
if message.author in userinteract:
user_response = input("Test")
await message.channel.send(user_response)
if message.content.startswith('$'):
userinteract.append(message.author)
if user_response in self.negative_responses:
await message.channel.send(user_response)
return
self.chat(user_response)
DiscordChatbot = ChatBot()
DiscordChatbot.start_chat()
client.run("TOKEN")
主体还没有完全实现,因为我试图在继续之前查看我的 Discord 机器人是否在线,但在 运行 时出现该错误。我该如何解决错误。已经尝试研究其他人遇到的类似问题,但无济于事。
我认为你的问题在于你这样定义 start_chat():
async def start_chat(self, message):
但是在你的程序结束时,你这样称呼它:
DiscordChatbot.start_chat()
您的错误意味着您尝试 运行、start_chat() 的方法需要括号中的消息,但找不到。
我不熟悉 discord.py 之类的东西(我很新,我只用过 vanilla Python),所以我不能说太多详细的东西,但我的建议是在其中放置一条测试消息:
DiscordChatbot.start_chat("whatever your test message is")
希望对您有所帮助!
-VDizz
我正在尝试为我的 Discord 聊天机器人创建主程序,但在尝试查看它是否运行时出现此错误:
Traceback (most recent call last):
File "C:\Users\amjad\OneDrive\Documents\Goldsmiths\Year 3\Final Year\Project\Test4\main.py", line 87, in <module>
DiscordChatbot.start_chat()
TypeError: start_chat() missing 1 required positional argument: 'message'
我的代码如下:
async def start_chat(self, message):
if message.author in userinteract:
user_response = input("Test")
await message.channel.send(user_response)
if message.content.startswith('$'):
userinteract.append(message.author)
if user_response in self.negative_responses:
await message.channel.send(user_response)
return
self.chat(user_response)
DiscordChatbot = ChatBot()
DiscordChatbot.start_chat()
client.run("TOKEN")
主体还没有完全实现,因为我试图在继续之前查看我的 Discord 机器人是否在线,但在 运行 时出现该错误。我该如何解决错误。已经尝试研究其他人遇到的类似问题,但无济于事。
我认为你的问题在于你这样定义 start_chat():
async def start_chat(self, message):
但是在你的程序结束时,你这样称呼它:
DiscordChatbot.start_chat()
您的错误意味着您尝试 运行、start_chat() 的方法需要括号中的消息,但找不到。
我不熟悉 discord.py 之类的东西(我很新,我只用过 vanilla Python),所以我不能说太多详细的东西,但我的建议是在其中放置一条测试消息:
DiscordChatbot.start_chat("whatever your test message is")
希望对您有所帮助! -VDizz