diff --git a/cogs/economy.py b/cogs/economy.py index 2e322b1..97303f1 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -884,7 +884,7 @@ async def pay(ctx, member:voltage.User, amount:str): parsed_amount = await parse_amount(ctx, amount) if parsed_amount is None: return await ctx.reply("Please enter a valid amount!") - if parsed_amount <= 0: + if round(int(parsed_amount)) <= 0: embed = voltage.SendableEmbed( title="Error!", description="Please enter a positive amount to pay.", @@ -901,15 +901,15 @@ async def pay(ctx, member:voltage.User, amount:str): await ctx.reply(embed=embed) return sender_data = await userdb.find_one({"userid": ctx.author.id}) - if sender_data and sender_data["economy"]["wallet"] >= amount: + if sender_data and round(sender_data["economy"]["wallet"]) >= round(parsed_amount): recipient_data = (await userdb.find_one({"userid": member.id})) if recipient_data: await userdb.bulk_write([ - pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.wallet": -amount}}), - pymongo.UpdateOne({"userid": member.id}, {"$inc": {"economy.wallet": -amount}}), - pymongo.UpdateOne({"userid": member.id}, {"$append": {"notifications.inbox": { + pymongo.UpdateOne({"userid": ctx.author.id}, {"$inc": {"economy.wallet": -round(parsed_amount)}}), + pymongo.UpdateOne({"userid": member.id}, {"$inc": {"economy.wallet": -round(parsed_amount)}}), + pymongo.UpdateOne({"userid": member.id}, {"$set": {"notifications.inbox.3": { "title": f"Payment from {ctx.author.display_name}", - "message": f"{ctx.author.display_name} paid you {round(amount, 2):,} coins!", + "message": f"{ctx.author.display_name} paid you `{round(parsed_amount):,}` coins!", "date": time.time(), "read": False, "type": "member" @@ -917,7 +917,7 @@ async def pay(ctx, member:voltage.User, amount:str): ]) embed = voltage.SendableEmbed( title="Success!", - description=f"You have successfully paid {round(amount, 2):,} to {member.display_name}.", + description=f"You have successfully paid `{round(parsed_amount):,}` to {member.display_name}.", colour="#198754" ) await ctx.reply(embed=embed) @@ -941,7 +941,7 @@ async def pay(ctx, member:voltage.User, amount:str): async def withdraw(ctx, *, amount): if (await userdb.find_one({"userid": ctx.author.id})): userdata = await parse_amount(ctx, amount, True) - if userdata >= 0: + if userdata >= 0 and userdata <= (await userdb.find_one({"userid": ctx.author.id}))['economy']['bank']: await userdb.bulk_write([ pymongo.UpdateOne( {"userid": ctx.author.id}, diff --git a/cogs/utility.py b/cogs/utility.py index 961a9b7..e5ebfae 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -94,6 +94,12 @@ async def profile(ctx, user: voltage.User = None): ) await ctx.reply(embed=embed) + @utility.command() + async def ping(ctx): + """Get the bot's ping!""" + # `{round((time.time() - ctx.message.created_at)*1000,2)}ms` + await ctx.reply(f"Pong!") + @utility.command() @limiter(10, on_ratelimited=lambda ctx, delay, *_1, **_2: ctx.send(f"You're on cooldown! Please wait `{round(delay, 2)}s`!")) async def stats(ctx): diff --git a/main.py b/main.py index f91aa86..69a2e16 100644 --- a/main.py +++ b/main.py @@ -34,7 +34,7 @@ """ -import random, motor, pymongo, json, time, asyncio, datetime, requests, pilcord +import random, motor, pymongo, json, time, asyncio, datetime, requests, pilcord, logging import voltage, os from voltage.ext import commands from voltage.errors import CommandNotFound, NotBotOwner, NotEnoughArgs, NotEnoughPerms, NotFoundException, BotNotEnoughPerms, RoleNotFound, UserNotFound, MemberNotFound, ChannelNotFound, HTTPError @@ -45,6 +45,12 @@ from bardapi import BardAsync from revoltbots import RBL +logging.basicConfig( + filename='app.log', + level=logging.DEBUG, + format='%(asctime)s - %(levelname)s - %(message)s' + ) + with open("json/config.json", "r") as f: config = json.load(f) @@ -721,6 +727,7 @@ def log_exceptions(type, value, tb): sys.__excepthook__(type, value, tb) # calls default excepthook sys.excepthook = log_exceptions +logger = logging.getLogger(__name__) # error handling shit @client.error("message") @@ -782,7 +789,7 @@ async def on_message_error(error: Exception, message): except: pass else: - raise(error) + logger.error(error) # Cog loading schenanigans