stock-tracker-discord/main.py

37 lines
784 B
Python

import discord
import database, table
from discord.ext import commands
from config import config
intents = discord.Intents.default()
bot = commands.Bot(
command_prefix="$",
intents=intents,
)
@bot.command()
async def ping(ctx):
await ctx.send("pong!")
@bot.command()
async def add(ctx, stock, amount):
try:
float(amount)
except ValueError:
await ctx.send("amoutn not a number")
return
user = str(ctx.message.author)
if database.add_stock(user, stock, amount):
return await ctx.send(str( "```" + table.generate_table(database.get_stocks(user)) + "```" ))
else:
return await ctx.send("Stock **{0}** does not exist!".format(stock))
bot.run('ODA5ODg1MjA2OTAyOTk3MDI0.YCbmYA.mFwhaYwHfRx-MLRAK1Qr0Ch2XjE')