我有这个功能
此功能不工作,无法打印 AttributeError:“非类型”对象没有属性“get” 如何修复
@self.client.event
async def on_message(message):
if message.author == self.client.user:
return
if self.check_buttons.get(message.author.id, None):
ans = None
for i in range(len(self.check_buttons.get(message.author.id, []))):
if self.check_buttons[message.author.id][i].lower() == message.content.lower() or message.content.lower() == "#" + str(i + 1):
ans = self.check_buttons[message.author.id][i]
break
if ans:
self.channel.send_message(message.author.id, ans)
self.check_buttons[message.author.id] = []
else:
msg = "You entered an invalid value. Copy (Short command: # and numbers buttons):\n"
for i in range(len(self.btns)):
msg += str(i + 1) + ". " + self.btns[i] + "\n"
self.send_message(message.author.id, msg)
else:
self.channel.send_message(message.author.id,
message.content) # send event (UserID + UserMessage) to channel```
将
if ans = self.check_buttons.get(message.author.id, None)
替换为if ans = self.check_buttons.get(message.author.id) == None:
相关问题 更多 >
编程相关推荐