首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >8启动8ball命令失败

8启动8ball命令失败
EN

Stack Overflow用户
提问于 2021-05-02 03:53:32
回答 2查看 50关注 0票数 0

我正在尝试重做我的机器人的8ball命令,我尝试使用以下代码

代码语言:javascript
复制
@client.command(aliases=['8ball'])
async def _8ball(ctx, *, question):
    responses = ['It is certain.',
                 'It is decidedly so.',
                 'Without a doubt.',
                 'Yes - definitely.',
                 'You may rely on it.',
                 'As I see it, yes.',
                 'Most likely.',
                 'Outlook good.',
                 'Yes.',
                 'Signs point to yes.',
                 'Reply hazy, try again.',
                 'Ask again later.',
                 'No.',
                 'Better not tell you now.',
                 'Cannot predict now.',
                 'Concentrate and ask again.',
                 "Don't count on it.",
                 'My reply is no.',
                 'My sources say no.',
                 'Outlook not so good.',
                 'Very doubtful.']
    responses = random.choice(responses)
    embed=discord.Embed(title="8ball", description="Ask the 8ball!", color=discord.Color.dark_purple())
    embed.add_field(name="Q: {question}", value="A: {responses}", inline=False)
    await ctx.send(embed=embed)

但是python文件拒绝启动,并返回

代码语言:javascript
复制
  File "C:\Users\r00t_technologies\Documents\bot\enigmatic-peak-21114\bot_development.py", line 135
    await ctx.send(embed=embed)
    ^
SyntaxError: 'await' outside function

有谁能帮我解决这个问题吗?

编辑:不要紧,我只是个笨蛋,看错了线,很抱歉给你带来不便(我在这方面有点经验不足)

EN

回答 2

Stack Overflow用户

发布于 2021-05-02 08:58:27

我不知道为什么这个错误说在函数外等待,但它已经在函数中了,我编辑了你的代码,我在我的Bot中测试了它,它工作得很好。

所以试试这个:

代码语言:javascript
复制
@client.command()
async def _8ball(ctx, *, question):
    responses = ['It is certain.',
                 'It is decidedly so.',
                 'Without a doubt.',
                 'Yes - definitely.',
                 'You may rely on it.',
                 'As I see it, yes.',
                 'Most likely.',
                 'Outlook good.',
                 'Yes.',
                 'Signs point to yes.',
                 'Reply hazy, try again.',
                 'Ask again later.',
                 'No.',
                 'Better not tell you now.',
                 'Cannot predict now.',
                 'Concentrate and ask again.',
                 "Don't count on it.",
                 'My reply is no.',
                 'My sources say no.',
                 'Outlook not so good.',
                 'Very doubtful.']
    responses = random.choice(responses)
    embed=discord.Embed(title="8ball", description="Ask the 8ball!", color=discord.Color.dark_purple())
    embed.add_field(name="Q: " + question, value="A:" + responses, inline=False)
    await ctx.send(embed=embed)
票数 0
EN

Stack Overflow用户

发布于 2021-05-02 12:14:33

在aliases =中需要有多个别名。尝试“8ball”,“8b”

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67350325

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档