首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我不和的机器人的命令突然停止听我的arg提示,然后完全停止工作

我不和的机器人的命令突然停止听我的arg提示,然后完全停止工作
EN

Stack Overflow用户
提问于 2020-08-01 23:20:37
回答 1查看 60关注 0票数 0

我试图写一个命令,收集免费球员在我们的本地篮球模拟服务器提供的CSV格式,以便我们可以更快和更有效地通过它们。我写了这个命令来接受报价,但突然间,我的论点就不再听我暗示的了:

async def offer(ctx, firstName: str, lastName: str, amount: float, length: int, option: str='no', ntc: str='no'):

它允许对lastName使用整数,即使我在这里使用了这些提示。它正常工作,只是如果您使用了错误的输入类型,它就不会抛出错误,然后突然我的异议机器人就完全停止了对这个命令的响应。它仍然正确地响应其他命令,所以这个命令有问题,我无法弄清楚.

下面是完整的命令:

代码语言:javascript
复制
@bot.command()
async def offer(ctx, firstName: str, lastName: str, amount: float, length: int, option: str='no', ntc: str='no'):

    team = ctx.channel.category.name
    username = ctx.author.name
    usermention = ctx.author.mention
    userid = ctx.author.id

    if option.lower() == 'po' or option.lower() == 'yes': option = 'yes'
    else: option = 'no'
    if ntc.lower() == 'ntc' or ntc.lower() == 'yes': ntc = 'yes'
    else: ntc = 'no'

    offer = (str(team) + ',' + str(username) + ',' + str(userid) + ',' + str(firstName) + ' ' + str(lastName) + ',' + str(amount) + ',' + str(length) + ',' + str(option) + ',' + str(ntc))
    offersList.append(offer)

    baseText = ('The ' + team + ' (' + usermention + ') offered ' + firstName + ' ' + lastName + ' a $' + str(amount) + ' million contract for ' + str(length) + ' years')
    if option == 'no' and ntc == 'no': text = (baseText + '.')
    if option == 'no' and ntc == 'yes': text = (baseText + ' with an NTC.')
    if option == 'yes' and ntc == 'no': text = (baseText + ' with a player option.')
    if option == 'yes' and ntc == 'yes': text = (baseText + ' with a player option and an NTC.')
    print(text)
    await ctx.send(text)

如果是明显的事情请告诉我,或者我必须重新考虑这个命令.谢谢大家!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-01 23:41:04

Ahmed问它是否在命令的开头执行了打印功能。一旦我添加了这个打印函数,突然整个命令又开始工作了。我不知道为什么,但它起作用了..。所以我不会碰它。LOL。谢谢各位。

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

https://stackoverflow.com/questions/63210949

复制
相关文章

相似问题

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