首页 > 解决方案 > 机器人在字符串中只说一个单词

问题描述

如标题。我试图让我的机器人发送通知,而不必使用“”来捕获整个句子。你到底是什么意思?

这是我的代码:

@bot.command(pass_context=True)
@discord.ext.commands.has_permissions(administrator=True)
async def announce(ctx, message : str):
    if message == None:
    return
    else:
        embed = discord.Embed(title='yBot  |  ANNOUNCEMENT', description='', color= 0xFF0000)
        embed.add_field(name="ANNOUNCEMENT: ", value="{}".format(message))
        embed.set_footer(text="© 2020 - Powered by yanuu ;k#2137")
        await ctx.send("||@everyone||")
        await ctx.send(embed=embed)

标签: discordbotsdiscord.py

解决方案


Your issue is in the way you defined the command it self. It should be with a * so that it will take everything after

async def announce(ctx,*, message : str):

Have a look at this doc


推荐阅读