Skip to content

Commit

Permalink
i couldnt tell ya tbf
Browse files Browse the repository at this point in the history
  • Loading branch information
2vw committed Apr 25, 2024
1 parent a5cda2c commit b6b9274
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
16 changes: 8 additions & 8 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -901,23 +901,23 @@ 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"
}}}),
])
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)
Expand All @@ -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},
Expand Down
6 changes: 6 additions & 0 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 9 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -782,7 +789,7 @@ async def on_message_error(error: Exception, message):
except:
pass
else:
raise(error)
logger.error(error)


# Cog loading schenanigans
Expand Down

0 comments on commit b6b9274

Please sign in to comment.