【问题标题】:Is there a command that I can use to send messages to other people in discord rewrite?有没有我可以用来在不和谐重写中向其他人发送消息的命令?
【发布时间】:2020-05-26 20:51:34
【问题描述】:

我供用户使用的不和谐命令是/dm @differentuser <message>

我可以使用什么命令行向特定成员发送直接消息?

我知道有author = ctx.message.authorawait author.send(msg)

【问题讨论】:

  • 另外,请只添加必要的标签,这样人们就会知道具体用哪种语言回答。

标签: python discord.py-rewrite


【解决方案1】:

您需要做的就是添加一个参数,命令将其视为成员对象,如下所示:

@bot.command()
async def dm(ctx, member: discord.Member, *, message):
    await member.send(message)
    await ctx.send(":white_check_mark: Sent!")

请记住,如果机器人无法发送消息,这将引发 Forbidden 错误。根据隐私设置,这可能是因为该成员阻止了该机器人,或者他们不接受来自该服务器的 DM。


参考资料:

【讨论】:

    猜你喜欢
    • 2021-03-28
    • 2018-12-15
    • 2020-10-03
    • 2018-04-29
    • 2021-04-03
    • 1970-01-01
    • 2020-07-28
    • 1970-01-01
    • 2020-11-12
    相关资源
    最近更新 更多