我试图写一个命令,收集免费球员在我们的本地篮球模拟服务器提供的CSV格式,以便我们可以更快和更有效地通过它们。我写了这个命令来接受报价,但突然间,我的论点就不再听我暗示的了:
async def offer(ctx, firstName: str, lastName: str, amount: float, length: int, option: str='no', ntc: str='no'):
它允许对lastName使用整数,即使我在这里使用了这些提示。它正常工作,只是如果您使用了错误的输入类型,它就不会抛出错误,然后突然我的异议机器人就完全停止了对这个命令的响应。它仍然正确地响应其他命令,所以这个命令有问题,我无法弄清楚.
下面是完整的命令:
@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)如果是明显的事情请告诉我,或者我必须重新考虑这个命令.谢谢大家!
发布于 2020-08-01 23:41:04
Ahmed问它是否在命令的开头执行了打印功能。一旦我添加了这个打印函数,突然整个命令又开始工作了。我不知道为什么,但它起作用了..。所以我不会碰它。LOL。谢谢各位。
https://stackoverflow.com/questions/63210949
复制相似问题