在 discord rewrite 中有没有我可以用来向其他人发送消息的命令?

Is there a command that I can use to send messages to other people in discord rewrite?

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

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

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

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

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

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


参考文献: