在discord.py中发送dm

2024-04-29 04:45:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图让它使用on_message事件向指定用户发送dm。 到目前为止,我已经从提到的用户那里获得了snowflake id,但是找不到向该用户发送dm的方法。 我已经找了好几个小时了,还没有找到一个工作人员,请帮忙


Tags: 方法用户idmessageon事件dm小时
1条回答
网友
1楼 · 发布于 2024-04-29 04:45:33

这取决于您使用的discord.py的版本,但假设您使用的版本高于1.0:

使用user.send(message)

更具体地说,我需要一段代码片段或更深入地描述您正试图做什么

要从提及中获取用户id,请执行以下操作:

Use a converter to get the User object:

@bot.command(name="id")
async def id_(ctx, user: discord.User):
    await ctx.send(user.id)

从这篇文章:How to get ID of a mentioned user (Discord.py)

相关问题 更多 >