如何让我的不和谐 py 机器人 dm 某人



所以我做了一个服务器需要的机器人,我想添加一个名为

!dm @(用户( (消息(

请提供任何帮助

假设您使用的是 discord.py 1.x 和 discord.ext.command:

import discord
from discord.ext import commands
...  # Bot definition if this is the main file
@bot.command()
async def dm(ctx, user: discord.User, *, message):
await user.send(message)

如果您的 Bot 实例变量被命名为不同的名称或它位于齿轮中,则需要稍微调整一下。

相关文档:

  • User.send((
  • 转换器(它如何变得不和谐。基于类型提示的用户实例(
  • 仅关键字参数,以避免在消息周围加上引号

最新更新