💵 Invest check
This commit is contained in:
@ -5,7 +5,7 @@ from discord.ext import commands
|
|||||||
from funcs import logThis, makeFiles
|
from funcs import logThis, makeFiles
|
||||||
|
|
||||||
commandPrefix = "!"
|
commandPrefix = "!"
|
||||||
client = commands.Bot(command_prefix=commandPrefix)
|
client = commands.Bot(command_prefix=commandPrefix, case_insensitive=True)
|
||||||
|
|
||||||
# Logs in
|
# Logs in
|
||||||
@client.event
|
@client.event
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import discord, asyncio, os, json
|
import discord, asyncio, os, json
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
|
||||||
from funcs import logThis, triviaAnswer, triviaCountPoints, triviaStart, deleteGame, checkBalance, giveMoney, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackHit, blackjackDouble, blackjackFinish, blackjackSplit, blackjackStand
|
from funcs import logThis, triviaAnswer, triviaCountPoints, triviaStart, deleteGame, checkBalance, giveMoney, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackHit, blackjackDouble, blackjackFinish, blackjackSplit, blackjackStand, parseInvest
|
||||||
|
|
||||||
from gameLoops import blackjackLoop, fiar, runMonopoly, runHex
|
from gameLoops import blackjackLoop, fiar, runMonopoly, runHex
|
||||||
|
|
||||||
@ -34,6 +34,11 @@ class GamesCog(commands.Cog):
|
|||||||
logThis("I didn't understand that (error code 1222)",str(ctx.message.channel.id))
|
logThis("I didn't understand that (error code 1222)",str(ctx.message.channel.id))
|
||||||
await ctx.send("I didn't understand that (error code 1222)")
|
await ctx.send("I didn't understand that (error code 1222)")
|
||||||
|
|
||||||
|
# Invest GwendoBucks in the stock market
|
||||||
|
@commands.command(aliases=["i"])
|
||||||
|
async def invest(self, ctx, *, content = "check"):
|
||||||
|
await ctx.send(parseInvest(content,str(ctx.message.author.id)))
|
||||||
|
|
||||||
# Runs a game of trivia
|
# Runs a game of trivia
|
||||||
@commands.command()
|
@commands.command()
|
||||||
async def trivia(self, ctx, *, content = ""):
|
async def trivia(self, ctx, *, content = ""):
|
||||||
|
@ -4,7 +4,7 @@ __all__ = ["helloFunc", "cap", "imageFunc", "logThis", "findWikiPage", "makeFile
|
|||||||
|
|
||||||
from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToCommand, fiarReactionTest, deleteGame, stopServer, addToDict, getName, getID, monopolyReactionTest
|
from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToCommand, fiarReactionTest, deleteGame, stopServer, addToDict, getName, getID, monopolyReactionTest
|
||||||
|
|
||||||
from .games import checkBalance, giveMoney, addMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI, parseHex, hexAI, parseMonopoly, monopolyContinue
|
from .games import checkBalance, giveMoney, addMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI, parseHex, hexAI, parseMonopoly, monopolyContinue, parseInvest
|
||||||
|
|
||||||
from .lookup import spellFunc, monsterFunc
|
from .lookup import spellFunc, monsterFunc
|
||||||
|
|
||||||
|
@ -8,3 +8,4 @@ from .blackjack import blackjackShuffle, blackjackStart, blackjackPlayerDrawHand
|
|||||||
from .fourInARow import parseFourInARow, fourInARowAI
|
from .fourInARow import parseFourInARow, fourInARowAI
|
||||||
from .hex import parseHex, hexAI
|
from .hex import parseHex, hexAI
|
||||||
from .monopoly import parseMonopoly, monopolyContinue
|
from .monopoly import parseMonopoly, monopolyContinue
|
||||||
|
from .invest import parseInvest
|
||||||
|
26
funcs/games/invest.py
Normal file
26
funcs/games/invest.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import finnhub
|
||||||
|
|
||||||
|
finnhubClient = finnhub.Client(api_key = "bsm16nvrh5rdb4ara3j0")
|
||||||
|
|
||||||
|
def getPrice(symbol : str):
|
||||||
|
res = finnhubClient.quote(symbol.upper())
|
||||||
|
if res == {}:
|
||||||
|
return 0
|
||||||
|
else:
|
||||||
|
print(res)
|
||||||
|
return int(res["c"] * 100)
|
||||||
|
|
||||||
|
def getPortfolio(user : str):
|
||||||
|
return None
|
||||||
|
|
||||||
|
def parseInvest(content: str, user : str):
|
||||||
|
if content.startswith("check"):
|
||||||
|
commands = content.split(" ")
|
||||||
|
if len(commands) == 1:
|
||||||
|
return getPortfolio(user)
|
||||||
|
else:
|
||||||
|
price = getPrice(commands[1])
|
||||||
|
if price == 0:
|
||||||
|
return f"{commands[1].upper()} is not traded on the american market."
|
||||||
|
else:
|
||||||
|
return "The current "+commands[1].upper()+" stock is valued at **"+str(price)+"** GwendoBucks"
|
Reference in New Issue
Block a user