所以我想做一个数字猜谜游戏discord机器人。一切正常,直到它到达终点(我希望它停止)。我意识到,即使代码结束了,机器人仍然在接受我说的话。我有没有办法阻止这一切的发生
(我才15岁,是python的新手,所以请耐心等待。) 这是我的密码:)
import keep_alive
import discord
import os
from discord.ext import commands
import random
import sys
number = random.randint(1, 100)
client = commands.Bot(command_prefix=".")
@client.event
async def on_ready():
print("The bot is online")
@client.command()
async def numpuz(ctx):
await ctx.send("Type a starting number")
@client.command()
async def num(ctx, chosennumber):
if chosennumber > str(number):
await ctx.send('number too high, pick a smaller one')
if chosennumber < str(number):
await ctx.send('number too small, pick a bigger one')
if chosennumber == str(number):
await ctx.send('YOU WON')
keep_alive.keep_alive()
client.run(os.getenv("token"))
目前没有回答
相关问题 更多 >
编程相关推荐