Issue
I have a bot which is supposed to give info on a player when in the command. The command is:
-Whois [USER]
and then the bot replies with the information.
I entered 'iamonf1r3' as the user parameter and it came up with the response for mip232. Here is my code:
@client.command()
async def Whois(parameter):
name = parameter
if name == "mip232" or name == "Mip" or "219884374378676224":
await client.say("Roblox Name: `mip232` \nDiscord Name: `Mip#3981` \nPin: `FS01` \nRank: `Chief Fire Officer` \nDivision: `All` \nActivity Level: `Active` \nDriving Level: `Advanced` \nDisciplinary Action: `None`")
elif name == "iamonf1r3" or "iamonf1r3" or "335014153460776962":
await client.say("Roblox Name: `iamonf1r3` \nDiscord Name: `iamonf1r3#7277` \nPin: `FS02` \nRank: `Deputy Chief Fire Officer` \nDivision: `All` \nActivity Level: `Active` \nDriving Level: `Advanced` \nDisciplinary Action: `None`")
Solution
You are using or in the wrong way
To be honest you completly messed your "or states" up
Every or has to have a new condition Right:
if name == "mip232" or name == "Mip" or "219884374378676224":
Wrong
if name == "mip232" or name == "Mip" or name == "219884374378676224":
You did the same with your elif but I'll leave it to you to fix this statement.
Explanation:
if <CONDITION> or <CONFITION>
The parameter "name" you gave in the first condition is not given to the second or.
Additionally if you ask if name
it will just see if this variable is present => True if present, False if None.
So your last or "219884374378676224"
basically returns a True for the if since "219884374378676224" is present because you just initialised it in the same block and it is not a query.
Try reading this: https://realpython.com/python-or-operator/
Answered By - Keyinator
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.