在我的 discord.py 代碼中,我試圖向消息作者指定的用戶設(shè)置一個簡單的發(fā)送消息。 if message.content.startswith('!hello'): print("Hello DIRECT MESSAGE") msg = "Why hello there" print (message.author) await client.send_message(message.author, msg)if message.content.startswith('!poke'): print("Poke DIRECT MESSAGE") a = message.content[6:] print(a) msg = "Hi there" await client.send_message(a, msg)!hello 命令工作正常,但我不知道如何在以字符串形式接收用戶 ID 后獲取用戶 ID 作為發(fā)送消息命令的對象。
1 回答

四季花海
TA貢獻1811條經(jīng)驗 獲得超5個贊
假設(shè)這發(fā)生在服務器中,其中命令調(diào)用程序和目標都是: target = discord.utils.get(message.server.members, id=a)
添加回答
舉報
0/150
提交
取消