discord.py message.channel.send无法正常工作

时间:2020-05-16 02:56:34

标签: python python-3.x discord.py

我正在使用discord.py制作二十一点游戏,我将Ace的值从11改为1,但是没有消息发送到通道,并且没有出现任何错误。

def ask_A(self):
    num_A = []
    for c in range(0, len(self.deck)):
        if self.deck[c].get_value() == "A" and self.deck[c].get_points() == 11:
            num_A.append(c)

    for i in num_A:
        message.channel.send(
            "Your current cards are " + str(self.print_cards()) + ", Total is " + str(self.sum_cards()) + "\n")
        self.deck[i].change_points(1)
        message.channel.send("Changed value of Ace to prevent loss")
        message.channel.send("Your cards are " + str(self.print_cards()) + ", Total is " + str(self.sum_cards()) + "\n")

1 个答案:

答案 0 :(得分:0)

您忘记了await您的声明。 docs中所有作为协程的东西都需要具有await表达式。

示例:

await message.channel.send("Hello! This is my message")

阅读有关异步IO here的信息。