🧹 Cleaning up cogs
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import discord
|
||||
|
||||
class Invest():
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
@ -103,35 +105,48 @@ class Invest():
|
||||
else:
|
||||
return "no"
|
||||
|
||||
def parseInvest(self, content: str, user : str):
|
||||
if content.startswith("check"):
|
||||
commands = content.split(" ")
|
||||
async def parseInvest(self, ctx, parameters):
|
||||
try:
|
||||
await ctx.defer()
|
||||
except:
|
||||
self.bot.log("Defer failed")
|
||||
user = f"#{ctx.author.id}"
|
||||
|
||||
if parameters.startswith("check"):
|
||||
commands = parameters.split(" ")
|
||||
if len(commands) == 1:
|
||||
return self.getPortfolio(user)
|
||||
response = self.getPortfolio(user)
|
||||
else:
|
||||
price = self.getPrice(commands[1])
|
||||
if price == 0:
|
||||
return f"{commands[1].upper()} is not traded on the american market."
|
||||
response = f"{commands[1].upper()} is not traded on the american market."
|
||||
else:
|
||||
price = f"{price:,}".replace(",",".")
|
||||
return f"The current {commands[1].upper()} stock is valued at **{price}** GwendoBucks"
|
||||
response = f"The current {commands[1].upper()} stock is valued at **{price}** GwendoBucks"
|
||||
|
||||
elif content.startswith("buy"):
|
||||
commands = content.split(" ")
|
||||
elif parameters.startswith("buy"):
|
||||
commands = parameters.split(" ")
|
||||
if len(commands) == 3:
|
||||
#try:
|
||||
return self.buyStock(user,commands[1],int(commands[2]))
|
||||
#except:
|
||||
# return "The command must be given as \"/invest buy [stock] [amount of GwendoBucks to purchase with]\""
|
||||
response = self.buyStock(user,commands[1],int(commands[2]))
|
||||
else:
|
||||
return "You must give both a stock name and an amount of gwendobucks you wish to spend."
|
||||
response = "You must give both a stock name and an amount of gwendobucks you wish to spend."
|
||||
|
||||
elif content.startswith("sell"):
|
||||
commands = content.split(" ")
|
||||
elif parameters.startswith("sell"):
|
||||
commands = parameters.split(" ")
|
||||
if len(commands) == 3:
|
||||
try:
|
||||
return self.sellStock(user,commands[1],int(commands[2]))
|
||||
response = self.sellStock(user,commands[1],int(commands[2]))
|
||||
except:
|
||||
return "The command must be given as \"/invest sell [stock] [amount of GwendoBucks to sell stocks for]\""
|
||||
response = "The command must be given as \"/invest sell [stock] [amount of GwendoBucks to sell stocks for]\""
|
||||
else:
|
||||
return "You must give both a stock name and an amount of GwendoBucks you wish to sell stocks for."
|
||||
response = "You must give both a stock name and an amount of GwendoBucks you wish to sell stocks for."
|
||||
|
||||
else:
|
||||
response = "Incorrect parameters"
|
||||
|
||||
if response.startswith("**"):
|
||||
responses = response.split("\n")
|
||||
em = discord.Embed(title=responses[0],description="\n".join(responses[1:]),colour=0x00FF00)
|
||||
await ctx.send(embed=em)
|
||||
else:
|
||||
await ctx.send(response)
|
||||
|
Reference in New Issue
Block a user