[英]Not sure how to continue this discord python code
我寫了一個名為guesstall
的函數,它是一個數字猜謎游戲。 我正在嘗試將代碼轉換為 discord bot 命令。 Discord 用戶應該能夠使用-guesstall
啟動游戲。
我對 Python 非常陌生,今天剛開始使用 discord.py。 任何幫助,將不勝感激。
async def guesstall(message):
n = int(random.randint(1, 50))
gjett = 5
while gjett > 0:
await message.channel.send("Guess a number")
t = message.content()
time.sleep(1)
if t == n:
await message.channel.send("Your guess was correct")
break
elif t < n:
await message.channel.send("The number is higher than your guess")
gjett -= 1
await message.channel.send("you have", str(gjett), "guesses left.")
await message.channel.send("")
elif t > n:
await message.channel.send("The number is smaller than your number")
gjett -= 1
await message.channel.send("You have", str(gjett), "guesses left.")
await message.channel.send("")
if gjett == 0:
await message.channel.send("You failed")
await message.channel.send("The number was", str(n))
if message.content.startswith("-guesstall"):
await guesstall(message)
你應該使用discord.py的重寫版本,它會讓它更容易
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.