discord.py - Discord.py 只向一个人发送消息
问题描述
我正在用 python 制作一个不和谐的机器人,我希望它只向输入命令的人发送消息,而不将其发送给其他任何人。有任何想法吗?
解决方案
见这里: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)
推荐阅读
- javascript - 无法在反应中扩展类组件,其他一切正常
- entity - 在 DDD 中,CRUD 操作是否可以独立于 AR 对聚合实体执行?
- php - 如何从带有 sql 的表中使用 php 获取选中的复选框
- ruby-on-rails - 无法使用标准地址(this).balance 获得智能合约地址余额;
- c - 在二维数组中找到最长的路径首先增加然后减少
- javascript - 通过json脚本读取一个Json文件并显示在网页中
- vim - vim中如何集成limelight?
- c - 来自 C 初学者的一个简单问题,关于数组
- java - Fillgrid 方法在井字游戏程序中不起作用
- gcc - 在 CUDA 编译期间,CLion 中的目标卸载过程中使用了错误的编译器