Reputation: 3
@client.command()
async def use(ctx, *, item=None):
if item == "watch" or "Watch":
res = await sell_this(ctx.author, item, 1)
if res[1] == 3:
await ctx.send(f"You don't have watch in your bag.")
return
responses = ["You looked at the watch and you realise it's 9:00PM and you have a date with a girl say COMING WAIT ME! before she kills you",
"You looked at the watch and you remmeber you have a meeting tomorrow and it's 2:00AM and then you realise it's a dream say 'WAKE UP WAKE UP' before you miss the interview",
"You looked at the watch and you realised it wasted 1 minute of your time say 'I LOVE TIME' before FBI comes raid your home", ]
# VARiABLES
users = await get_bank_data()
user = ctx.author
earnings = random.randrange(0, 6200)
bad = random.randrange(0, 4200)
if not res[0]:
if res[1] == 1:
await ctx.send("That Object isn't there!")
return
if res[1] == 2:
await ctx.send(f"You don't have {item} in your bag.")
return
if res[1] == 3:
await ctx.send(f"You don't have {item} in your bag.")
return
wat = random.choice(responses)
await ctx.send(wat)
def check(message):
return message.author == ctx.author
if wat == responses[0]:
try:
response = await client.wait_for('message', check=check, timeout=8)
if response.content == "COMING WAIT ME!":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**Coming wait me {earnings} coins**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**DIVORCED π**! Your wife took {bad} coins from you. and she took your lovely kid π**")
except:
await ctx.send(f"**DIVORCED π**! Your wife took {bad} coins from you. and she took your lovely kid π")
users[str(user.id)]["wallet"] -= bad
with open("bank.json", "w") as f:
json.dump(users, f, indent=4)
if wat == responses[1]:
try:
response = await client.wait_for('message', check=check, timeout=8)
if response.content == "WAKE UP WAKE UP":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**AMAZING JOB you didn't miss you meeting good job here take {earnings} coins :))**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**MISSED MEETING π‘**! You missed your meeting and your wife took your 120 lovely kids and stole {bad} coins from you π")
except:
await ctx.send(f"**MISSED MEETING π‘**! You missed your meeting and your wife took your 120 lovely kids and stole {bad} coins from you π")
users[str(user.id)]["wallet"] -= bad
with open("bank.json", "w") as f:
json.dump(users, f, indent=4)
if wat == responses[2]:
try:
response = await client.wait_for('message', check=check, timeout=8)
if response.content == "I LOVE TIME":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**Good job, FBI gave you {earnings} coins for being a good boy**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**JAiLED! π’π‘**! FBI Jailed you and took {bad} coins from you. and you are now jailedπ**")
except:
await ctx.send(f"**JAiLED! π’π‘**! FBI Jailed you and took {bad} coins from you. and you are now jailedπ**")
users[str(user.id)]["wallet"] -= bad
with open("bank.json", "w") as f:
json.dump(users, f, indent=4)
if item == "lolipop" or "Lolipop":
res = await sell_this(ctx.author, item, 1)
if res[1] == 3:
await ctx.send(f"You don't have lolipop in your bag.")
return
questions = ["You used your lolipop and you enjoyed it",
"Your lolipop cried.", ]
# VARiABLES
users = await get_bank_data()
user = ctx.author
earnings = random.randrange(0, 6200)
bad = random.randrange(0, 4200)
if not res[0]:
if res[1] == 1:
await ctx.send("That Object isn't there!")
return
if res[1] == 2:
await ctx.send(f"You don't have {item} in your bag.")
return
if res[1] == 3:
await ctx.send(f"You don't have {item} in your bag.")
return
wat = random.choice(questions)
return await ctx.send(wat)
if item == "laptop" or "Laptop":
res = await sell_this(ctx.author, item, 1)
if res[1] == 3:
await ctx.send(f"You don't have watch in your bag.")
return
randomword = ["ytoueb", "poitsfy", "suimc", "ssa", "fcuk"]
chuse = random.choice(randomword)
mustchoose = ["You looked at the laptop and you saw there is a hot deal but you have 50/50 chance of winning it say 'START' to take the deal",
f"You looked at the watch and you realised it wasted 1 minute of your ugly face Complete the word to earn money or u lost money the word is '`{chuse}`'", ]
# VARiABLES
users = await get_bank_data()
user = ctx.author
earnings = random.randrange(0, 6200)
bad = random.randrange(0, 4200)
if not res[0]:
if res[1] == 1:
await ctx.send("That Object isn't there!")
return
if res[1] == 2:
await ctx.send(f"You don't have {item} in your bag.")
return
if res[1] == 3:
await ctx.send(f"You don't have {item} in your bag.")
return
chancebot = random.choice(range(0, 10))
chanceme = random.choice(range(0, 10))
wat = random.choice(mustchoose)
await ctx.send(wat)
def check(message):
return message.author == ctx.author
if wat == mustchoose[0]:
try:
response = await client.wait_for('message', check=check, timeout=8)
if response.content == "START":
if chancebot > chanceme:
lostembed = discord.Embed(
title="**You LOST**", colour=discord.Color.red())
lostembed.add_field(
name=f"Your chance:", value=f"`{chanceme}`")
lostembed.add_field(
name=f"My chance:", value=f"`{chanceme}`")
await ctx.send(embed=lostembed)
await ctx.send(f"You lost {earnings} coins :(")
users[str(user.id)]["wallet"] -= earnings
if chanceme > chancebot:
wonembed = discord.Embed(
title="**You WON!**", colour=discord.Color.green())
wonembed.add_field(
name=f"Your chance:", value=f"`{chanceme}`")
wonembed.add_field(
name=f"My chance:", value=f"`{chanceme}`")
await ctx.send(embed=wonembed)
await ctx.send(f"You WON {earnings} coins LESH GOOOO")
users[str(user.id)]["wallet"] += earnings
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**Wrong... :(( lost {bad} for participating**")
except:
await ctx.send(f"**Time is out you lost {bad} coins for participating**")
users[str(user.id)]["wallet"] -= bad
with open("bank.json", "w") as f:
json.dump(users, f, indent=4)
if wat == mustchoose[1]:
if chuse == randomword[0]:
try:
response = await client.wait_for('message', check=check, timeout=20)
if response.content == "youtube":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
except:
await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
users[str(user.id)]["wallet"] -= bad
if chuse == randomword[1]:
try:
response = await client.wait_for('message', check=check, timeout=20)
if response.content == "spotify":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
except:
await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
users[str(user.id)]["wallet"] -= bad
if chuse == randomword[2]:
try:
response = await client.wait_for('message', check=check, timeout=20)
if response.content == "music":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
except:
await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
users[str(user.id)]["wallet"] -= bad
if chuse == randomword[3]:
try:
response = await client.wait_for('message', check=check, timeout=8)
if response.content == "ass":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
except:
await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
users[str(user.id)]["wallet"] -= bad
if chuse == randomword[4]:
try:
response = await client.wait_for('message', check=check, timeout=8)
if response.content == "fuck":
users[str(user.id)]["wallet"] += earnings
return await ctx.send(f"**AMAZING JOB you guessed the word good job here take {earnings} coins :))**")
else:
users[str(user.id)]["wallet"] -= bad
return await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
except:
await ctx.send(f"**WRONG WORD π‘**! Very very bad job.. i will steal {bad} coins from you :P")
users[str(user.id)]["wallet"] -= bad
with open("bank.json", "w") as f:
json.dump(users, f, indent=4)
ALright so this code is basically to use an item and it works but it keeps sending watch questions even if i say *use laptop so like if i say *use laptop it will first send a watch question then lolipop question i think then a laptop question how to fix it? Everything is appreciated and again i just wanna make it so it can work <3
Upvotes: 0
Views: 63
Reputation: 644
As @lemonhead mentioned in his comment
a non-empty string clause actually reads as an always True statement from a python truthiness perspective. So when you say
if item == "laptop" or "Laptop"
it's the same as sayingif item == "laptop" or True
; it always evaulates to True
The correct way would be if item == "watch" or item == "Watch"
, but there are a few other ways to do it:
.lower()
converts a string to all lowercase, "WaTch"
-> "watch"
if item.lower() == "watch":
if you have multiple options like "laptop" and "notebook", if item.lower() == "laptop" or item.lower() == "notebook"
would get super long.
instead you can check if the item is in
a list
if item.lower() in ["laptop", "notebook"]:
Upvotes: 1