简体   繁体   English

带有命令的机器人 discord python 消息

[英]bot discord python message with commands

@bot.command()
@commands.has_role("Administrator")
async def mp(ctx, message):
    await ctx.channel.purge(limit=1)
    await ctx.send(message)`

Hello, I do not know why but it does not take all the arguments, it puts only the first word and not those behind你好,我不知道为什么,但它并没有占用所有的 arguments,它只放第一个词而不是后面的那些

This is how the commands module works, the message will be split into words and fed to your function separately.这就是commands模块的工作方式,消息将被拆分为单词并分别发送给您的 function。 As per the documentation , you can put quotes around words to have them arrive as a single argument.根据文档,您可以在单词周围加上引号,以使它们作为单个参数到达。

If you want the full message, you can get it as ctx.message.content如果你想要完整的消息,你可以得到它作为ctx.message.content

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM