如何在 discord.py 中发送消息

How to send a message in discord.py

如何在用户键入命令时发送正常消息?我试过使用@client.command 异步定义 ping 但它不起作用 D:

您可以使用 await ctx.send("Your message here"),确保您在 @client.command 中传递了 Context。 如果您还有其他问题,请随时问我:)

如果有帮助,请将此作为指南

@client.command
async def ping(ctx):
await ctx.send("Your message")

这里ctx是上下文,hi是命令

代码:

@client.command
async def hi(ctx):
    await ctx.send("Message which you want to send")