gpt4 book ai didi

python-3.x - 无法在成员加入时发送消息 (discord.py)

转载 作者:行者123 更新时间:2023-12-05 07:07:00 24 4
gpt4 key购买 nike

async def on_member_join(member):
await bot.send_message(member, "Welcome !")

这是我的代码。当我的成员加入服务器时,我得到这个:

Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Users\pauls\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "C:/Users/pauls/OneDrive/Bureau/Discord UHC/PandaBot/main.py", line 19, in on_member_join
await bot.send_message(member, "Welcome !")
AttributeError: 'Bot' object has no attribute 'send_message'

有人可以帮我吗?

最佳答案

如果您想向连接的用户发送直接消息,我认为这对您有帮助:

async def on_member_join(member):
await member.send("Welcome!")

关于python-3.x - 无法在成员加入时发送消息 (discord.py),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62298764/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com