【问题标题】:How to send a private message on discord [closed]如何在不和谐上发送私人消息[关闭]
【发布时间】:2021-06-30 06:25:31
【问题描述】:

我希望 Python discord 机器人向不和谐用户发送消息,例如“Sammie#2596”

我如何向这样的用户发送私人消息?

【问题讨论】:

标签: python discord message private


【解决方案1】:

向成员发送直接消息的简单命令可以是:

@client.command() / @bot.command() / @commands.command()
async def dm(ctx, user: discord.Member, *, message):
    await user.send(f"{message}")
  • * 用于允许多个单词
  • discord.Member 可以是 ID/标签,也可以是您提及的用户
  • 确保打开 Intent 并将其导入到您的代码中。

要获取所有用户的列表,请查看 StackOverflow 上的其他帖子:12

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-28
    • 2018-11-19
    • 2019-06-25
    • 2018-01-13
    • 2018-12-15
    • 2020-05-31
    • 2022-11-02
    • 2021-08-07
    相关资源
    最近更新 更多