python - discord.py 自定义帮助信息
问题描述
我正在制作一个不和谐的机器人,我想要一个自定义的帮助消息。我试过:
from discord.ext import commands
bot = commands.Bot(command_prefix="!")
@bot.command()
async def help(ctx):
member = ctx.author
await ctx.send(member, "test successful")
bot.run('TOKEN')
它应该向用户发送私人消息并发送任何内容。但是当我进入!help
机器人时,它甚至不会对消息做出反应。
解决方案
发送消息只有一个位置参数(消息本身)和选项。为了发送 DM 消息,您需要改为在成员类上发送。
await member.send("test successful")
推荐阅读
- java - ObjectMapper - 将字符串解析为对象
- java - 在使用 smbd 或 ssh 协议删除任何目录之前,我是否必须递归删除所有文件和文件夹?
- ios - 使用 UICollectionViewFlowLayout 排列 CollectionView 单元格。需要使细胞看起来更大
- flutter - 颤振堆栈重叠每个容器
- android - 在智能手机中禁用小部件 android
- nginx - Nginx 入口没有正确解析 kube-prometheus-stack 的路径
- node.js - tsc 和 ng build 什么都不做,Angular 更新后完全没有响应
- mongodb - Apache NiFi 与 Compass 的连接
- node.js - Puppeteer:在隐身上下文之间共享缓存
- c++ - serpent 加密密钥调度,如何填充密钥以扩展为 256 位