[英]Issue saving message to json file discord.py rewrite
我試圖將每個用戶的最新消息保存到附加到其用戶ID的JSON文件。 有些東西會被寫入文件,但它不是原始消息。
async def on_message(self, msg):
if msg.author == self.client.user:
return
with open("users.json") as f:
users = json.load(f)
users[str(msg.author.id)]['response'] = str(msg)
with open('users.json', 'w') as f:
json.dump(users, f)
我希望輸出是用戶發送的原始消息,但我得到了一些東西
"<Message id=585702897673699338 pinned=False author=<Member id=344030587884929025 name='Siiant' discriminator='5767' bot=False nick=None guild=<Guild id=555525798090768446 name='Bot Test' chunked=True>>>"
這是Message
對象的字符串表示形式。 要獲取消息的內容,請使用msg.content
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.