discord.py bot的on_message函数出错

2024-09-30 18:27:34 发布

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

除了我创建的send_message函数外,整个bot都可以工作

@client.event
async def send_winners():
    img = Image.open("placement_temp.jpg")

    send_winners = json.loads(open('send_message.json').read())

    if send_winners == True:
        channel = 686026687145705505 #648365930639785985   


        await message.channel.send(channel, "<@&684816171316412458> And the Winners of this week are:", img)  # Error happening here
        send_winners = no
        with open("winner_send.json", "w") as fp:
            json.dump(send_winners, fp)
    await asyncio.sleep(10)

Tags: 函数clienteventsendjsonmessageimgasync
1条回答
网友
1楼 · 发布于 2024-09-30 18:27:34

试试这个:

@client.event
async def send_winners(message):

    send_winners = json.loads(open('send_message.json').read())

    if send_winners == True:
        channel = 686026687145705505 #648365930639785985   


        await message.channel.send(channel, "<@&684816171316412458> And the Winners of this week are:", Image.open("placement_temp.jpg"))  # Error happening here
        send_winners = no
        with open("winner_send.json", "w") as fp:
            json.dump(send_winners, fp)
    await asyncio.sleep(10)

相关问题 更多 >