首页 > 解决方案 > client.send_file 发送图像为 0 字节不和谐 py

问题描述

每当 await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi2.png')命中时,将一个 0 字节的文件而不是实际图像发送到通道。文件大小约为 52kb,相当小。最后发送的图像显示没有问题 ( await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi.png'))

elif slot1 == '<:papii:492030512760750090>' and slot2 == '<:papii:492030512760750090>' and slot3 == '<:papii:492030512760750090>':
    await client.edit_message(mtg, "\t{}".format(slotOutput))
    await client.send_file(client.get_channel('491846919262437377'), 'slots2.png')
    await client.send_message(message.channel, " {} hit 3 <:papii:492030512760750090>'s for $800! ".format(message.author.mention))
    await client.send_message(message.channel, "{} moves onto the bonus round for a chance to win the jackpot!".format(message.author.mention))
    add_dollars(message.author, 800)
    remove_dollars(message.author, 10)

    #JACKPOT BONUS ROUND

    await asyncio.sleep(3)
    await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi2.png')
    jck = await client.send_message(message.channel, "{}".format(jackOutput))
    await client.edit_message(jck, "{}".format(animationjack))
    await client.edit_message(jck, "{}".format(animationjack2))
    await client.edit_message(jck, "{}".format(animationjack3))
    if jack1 == '' and jack2 == '' and jack3 == '' and jack4 == '' and jack5 == '':
        await client.edit_message(jck, "{}".format(jackOutput)) 
        await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi.png')
        await client.send_message(message.channel, " CONGRATS {}! You've hit 5 's for an additional $1000! ".format(message.author.mention))
        add_dollars(message.author, 1000)
    elif jack1 == '' and jack2 == '' and jack3 == '' and jack4 == '' and jack5 == '':
        await client.edit_message(jck, "{}".format(jackOutput)) 
        await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi.png')
        await client.send_message(message.channel, " CONGRATS {}! You've hit 5 's for an additional $1250! ".format(message.author.mention))
        add_dollars(message.author, 1250)
    elif jack1 == '<:papi:492025149525327902>' and jack2 == '<:papi:492025149525327902>' and jack3 == '<:papi:492025149525327902>' and jack4 == '<:papi:492025149525327902>' and jack5 == '<:papi:492025149525327902>':
        await client.edit_message(jck, "{}".format(jackOutput)) 
        await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi.png')
        await client.send_message(message.channel, " CONGRATS {}! YOU'VE WON THE JACKPOT FOR AN ADDITIONAL $2000! ".format(message.author.mention))
        add_dollars(message.author, 2000)
    else:
        await client.edit_message(jck, "{}".format(jackOutput)) 
        await client.send_file(client.get_channel('491846919262437377'), 'jackpotpapi.png')
        await client.send_message(message.channel, "Better luck next time {}!".format(message.author.mention))

标签: pythonpython-3.xdiscorddiscord.py

解决方案


推荐阅读