Код: Выделить всё
@bot.command(name="mission")
async def mission(ctx):
scenarioslist = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]
catnamelist = ['Mittens', 'Milo', 'Luna', 'Mochi', 'Tigger', 'Misty']
catcolorlist = ['Siamese', 'Persian', 'hairless', 'tabby', 'munchkin', 'Maine Coon']
catsizelist = ['', 'big', 'massive', 'small', 'tiny']
user = ctx.message.author
guild = ctx.guild.id
table = "PEOPLE_" + str(guild)
passfail1 = random.randint(1, 10)
passfail2 = random.randint(1, 9)
location = random.randint(1, 3)
scenarios = random.choice(scenarioslist)
catname = random.choice(catnamelist)
catcolor = random.choice(catcolorlist)
catsize = random.choice(catsizelist)
try:
connection = mysql.connector.connect(
host="localhost",
port="3306",
user="root",
password="root",
database="naruto_game"
)
cursor = connection.cursor()
sql_select_query = "SELECT * from " + table + " where user like '"+ str(ctx.message.author) +"'"
cursor.execute(sql_select_query)
record = cursor.fetchall()
for row in record:
if row[5] == "Genin" and row [6] < 800:
await ctx.send("You will be embarking on an F-Rank mission. Are you ready?")
msg = await bot.wait_for("message", check=lambda m: m.channel == ctx.channel and m.author == user)
decision = msg.content
if decision == "yes":
if passfail1 < 10:
if location == 1 and scenarios == [6]:
await ctx.send("Mrs. Nishina, one of the village elders, cat has gone missing. You've been assigned to find and return it to her.")
await asyncio.sleep(2)
await ctx.send(f"You go to Mrs. Nishina's home to find out as much information as you can about the cat. She tells you that her missing cat is a {catsize} {catcolor} cat named {catname}.")
elif passfail1 == 10:
if location == 1:
print("")
else:
await ctx.send(f"You didn't say {str('"yes"')}, so I'm ending the mission.")
except mysql.connector.Error as error:
print("Failed to find name: {}".format(error))
finally:
if connection.is_connected():
cursor.close()
connection.close()
print("MySQL connection has been closed.")
Подробнее здесь: https://stackoverflow.com/questions/790 ... -yes-or-no