不一致py“int不可调用”

2024-10-03 11:20:02 发布

您现在位置:Python中文网/ 问答频道 /正文

哦,天哪,我来了另一个破坏系统。。。因此,我对discord机器人编码非常陌生,但我有上下的一切,这是一个糟糕的命令。上面说这两条带巨大箭头的线就是罪魁祸首,如果你看到这一点的话,还有阿迪蒂亚·托马尔。是的,我正在做另一个,不,我不知道为什么。。。我输入的命令是?fight,后面跟着15个其他数字

discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'int' object is not callable是错误的具体原因

###Le epic variables###
WWT = 0
AAS = 0
ASTR = 0
ASPD = 0
DAS = 0
AL = 0
DL = 0
TB = 0
DR = 0
AR = 0
DP = 0
SB = 0
DD = 0
ASK = 0
WC = 0
CC = 0
DoubleAtk = 1
critatk = 1


###Le epic command###
@client.command()
async def fight(ctx, WWT : int, ASTR : int, ASPD : int, DAS : int, AL : int, DL : int, TB : int, DR : int, AR : int, DP : int, SB : int, DD : int, ASK : int, WC : int, CC : int):
    global AAS
    global critatk
    if WWT > ASTR():                    <---------------------- this thing
        AAS = ASPD - (WWT - ASTR)
    else:
        AAS = ASPD
    global DoubleAtk
    if (AAS - DAS) > 4():                 <-------------------- and this thing
        DoubleAtk = 2
    crit_rate = ((WC + ASK) / 2) + SB + CC
    def did_crit():
        random.randint(1, 100)
    DP = TB + DR + SB
    Avoid = AAS + (AL / 2) + TB

    for i in range(DoubleAtk):
        did_crit()
        if did_crit == crit_rate():
            critatk = 3
        damage = (ASTR - DD) * critatk
        await ctx.send(damage)

Tags: tbddintsbdpalaasdr
2条回答

从我所看到的情况来看,我认为在那些if语句中不需要在ASTR4后面加括号。试试这个:

if WWT > ASTR:                  
        AAS = ASPD - (WWT - ASTR)
    else:
        AAS = ASPD
    global DoubleAtk
    if (AAS - DAS) > 4:       
        DoubleAtk = 2

您试图调用一些参数,就好像它们是函数一样,错误基本上是告诉您不能调用参数,例如在if WWT > ASTR(): if (AAS - DAS) > 4():中,您将整数作为函数调用,而函数是不可调用的

更正后的代码应如下所示:

###Le epic variables###
WWT = 0
AAS = 0
ASTR = 0
ASPD = 0
DAS = 0
AL = 0
DL = 0
TB = 0
DR = 0
AR = 0
DP = 0
SB = 0
DD = 0
ASK = 0
WC = 0
CC = 0
DoubleAtk = 1
critatk = 1


###Le epic command###
@client.command()
async def fight(ctx, WWT : int, ASTR : int, ASPD : int, DAS : int, AL : int, DL : int, TB : int, DR : int, AR : int, DP : int, SB : int, DD : int, ASK : int, WC : int, CC : int):
    global AAS
    global critatk
    if WWT > ASTR:                    
        AAS = ASPD - (WWT - ASTR)
    else:
        AAS = ASPD
    global DoubleAtk
    if (AAS - DAS) > 4:   
        DoubleAtk = 2
    crit_rate = ((WC + ASK) / 2) + SB + CC
    def did_crit():
        random.randint(1, 100)
    DP = TB + DR + SB
    Avoid = AAS + (AL / 2) + TB

    for i in range(DoubleAtk):
        did_crit()
        if did_crit() == crit_rate:
            critatk = 3
        damage = (ASTR - DD) * critatk
        await ctx.send(damage)

注意did_crit()实际上需要作为函数调用(因为它是函数),而crit_rate不需要,因为它是整数

相关问题 更多 >