Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python:discord.py猜游戏未执行_Python_Python 3.x_Discord_Discord.py - Fatal编程技术网

python:discord.py猜游戏未执行

python:discord.py猜游戏未执行,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我已经导入了以下所需的所有模块; 当我在Discord服务器上键入$game时,机器人不会做出反应 async def game(self,ctx): number = random.randint(1,100) for i in range(0,5): await ctx.send("Guess") response = await self.bot.wait_for("message") guess = in

我已经导入了以下所需的所有模块; 当我在Discord服务器上键入
$game
时,机器人不会做出反应

async def game(self,ctx):
  number = random.randint(1,100)
  for i in range(0,5):
      await ctx.send("Guess")
      response = await self.bot.wait_for("message")
      guess = int(response.content)
      if guess > number:
          await ctx.send("The Number is greater")
      elif guess < number:
         await ctx.send("The number is smaller")
      else:
         await ctx.send("You guessed the number!!")
async def游戏(self,ctx):
number=random.randint(1100)
对于范围(0,5)内的i:
等待ctx发送(“猜测”)
响应=等待self.bot.wait_for(“消息”)
guess=int(response.content)
如果猜测>数字:
等待ctx.send(“数字更大”)
elif guess<数字:
等待ctx.send(“号码较小”)
其他:
等待ctx.send(“你猜到了号码!!”)

您是否已使用
命令对函数进行了修饰。command()
?首先,请参考上面的注释,其次,在
等待
中,您没有检查用户是否与运行命令的用户相同,是否在同一频道中。我对这个问题的回答对您有帮助吗?