当某人使用 discord.py 加入服务器时,如何向他们发送直接消息
How do I send a direct message to someone when they join a server with discord.py
我正在为我的 discord 服务器编写一个机器人,我想向第一次加入服务器的任何人发送一条自动直接消息。我查看了文档,但找不到有关如何执行此操作的任何信息。我正在使用 python 3.5 和 discord.py 版本 0.16.12.
https://discordpy.readthedocs.io/en/latest/api.html#discord.on_member_join
您可以按照以下方式做一些事情:
await bot.send_message(member, "hello")
如果您使用的是 discord py 重写,这应该可以工作
确保您已启用机器人的意图,如图所示
intents=discord.Intents.all()
client = commands.Bot(command_prefix= cmd,intents=intents)
@client.event
async def on_member_join(member):
await member.send(f"your welcome message here")
我正在为我的 discord 服务器编写一个机器人,我想向第一次加入服务器的任何人发送一条自动直接消息。我查看了文档,但找不到有关如何执行此操作的任何信息。我正在使用 python 3.5 和 discord.py 版本 0.16.12.
https://discordpy.readthedocs.io/en/latest/api.html#discord.on_member_join
您可以按照以下方式做一些事情:
await bot.send_message(member, "hello")
如果您使用的是 discord py 重写,这应该可以工作
确保您已启用机器人的意图,如图所示
intents=discord.Intents.all()
client = commands.Bot(command_prefix= cmd,intents=intents)
@client.event
async def on_member_join(member):
await member.send(f"your welcome message here")