首页 > 解决方案 > Discord.py 只向一个人发送消息

问题描述

我正在用 python 制作一个不和谐的机器人,我希望它只向输入命令的人发送消息,而不将其发送给其他任何人。有任何想法吗?

标签: discord.py

解决方案


见这里:https ://discordpy.readthedocs.io/en/rewrite/ext/commands/commands.html#converters

from discord.ext import commands
import discord

bot = commands.Bot(command_prefix='!')

@bot.command(name='your_command')
async def DM(user: discord.User, message="Hi"):
    await user.send(message)

推荐阅读