我在python上安装了我的不和谐欢迎程序,这是错误消息:
on_member_join中的文件“ welcome-bot.py”,第27行 等待client.send_message(成员,newUserMessage) AttributeError:“客户端”对象没有属性“ send_message”
import discord
import asyncio
client=discord.Client()
@client.event
async def on_ready():
print('logged in as')
print(client.user.name)
print(client.user.id)
print('-----')
newUserMessage = """
is
that
works?
"""
@client.event
async def on_member_join(member):
print("Recognised that a member called " + member.name + " joined")
await client.send_message(member, newUserMessage)
print("Sent message to " + member.name)```
答案 0 :(得分:0)
Client
不包含名为send_message
的函数,您可以在其中PM / DM用户。
相反,您可以从加入的成员那里获取dm_channel
属性,并在该频道中发送消息:
joinedUserDM = member.dm_channel
if joinedUserDM is None:
await member.create_dm()
joinedUserDM = member.dm_channel
joinedUserDM.send("message to send to the joined user's private inbox")