首页 > 解决方案 > 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机器人时,它甚至不会对消息做出反应。

标签: pythonpython-3.xdiscorddiscord.py

解决方案


发送消息只有一个位置参数(消息本身)和选项。为了发送 DM 消息,您需要改为在成员类上发送。

await member.send("test successful")

推荐阅读