Skip to content

Commit

Permalink
some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
2vw committed Mar 5, 2024
1 parent 3a8f717 commit 65cb5c5
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,5 @@ cython_debug/
.gitignore
/.gitignore
/json/config.json
/asd.txt
/asd.txt
/user_ids.txt
154 changes: 125 additions & 29 deletions cogs/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ async def deposit(ctx, amount):

@eco.command(name="coinflip", aliases=['cf', 'coin', 'flip'], description="Flip a coin!")
@limiter(7, on_ratelimited=lambda ctx, delay, *_1, **_2: ctx.send(f"You're on cooldown! Please wait `{round(delay, 2)}s`!"))
async def coinflip(ctx, bet:int=None, choice:str=None):
async def coinflip(ctx, user:voltage.User=None, bet:int=None, choice:str=None):
if not bet or bet < 0:
return await ctx.reply("Please enter a valid bet!")
else:
Expand All @@ -517,48 +517,144 @@ async def coinflip(ctx, bet:int=None, choice:str=None):
)
return await ctx.reply(embed=embed)
elif (await userdb.find_one({"userid": ctx.author.id})):
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"Flipping a coin for **\${bet:,}**... {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']-bet:,}` in your wallet!",
colour="#00FF00",
media = "https://media.tenor.com/images/60b3d58b8161ad9b03675abf301e8fb4/tenor.gif"
)
msg = await ctx.reply(embed=embed)
await userdb.bulk_write([
pymongo.UpdateOne(
{"userid": ctx.author.id},
{"$inc": {"economy.wallet": -bet}}
if not user:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"Flipping a coin for **\${bet:,}**... {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']-bet:,}` in your wallet!",
colour="#00FF00",
media = "https://media.tenor.com/images/60b3d58b8161ad9b03675abf301e8fb4/tenor.gif"
)
])
await asyncio.sleep(3)
if random.choice(['heads', 'tails']) == choice.lower():
msg = await ctx.reply(embed=embed)
await userdb.bulk_write([
pymongo.UpdateOne(
{"userid": ctx.author.id},
{"$inc": {"economy.wallet": bet*2}}
{"$inc": {"economy.wallet": -bet}}
)
])
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"You won **\${bet:,}**! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#00FF00"
)
return await msg.edit(embed=embed)
await asyncio.sleep(3)
if random.choice(['heads', 'tails']) == choice.lower():
await userdb.bulk_write([
pymongo.UpdateOne(
{"userid": ctx.author.id},
{"$inc": {"economy.wallet": bet*2}}
)
])
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"You won **\${bet:,}**! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#00FF00"
)
return await msg.edit(embed=embed)
else:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"You lost **\${bet:,}**! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#FF0000"
)
return await msg.edit(embed=embed)
else:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"You lost **\${bet:,}**! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#FF0000"
description=f"{ctx.author.display_name}, challenges {user.display_name} to a coinflip for **\${bet:,}*! {sep}Do you confirm? (15 seconds)",
colour="#00FF00"
)
return await msg.edit(embed=embed)

await ctx.send(embed=embed, content=user.mention)
try:
def check(msg):
return msg.author.id == user.id
msg = await client.wait_for("message", check=check, timeout=15)
if msg.content.lower() in ["yes", "y", "yea", "yeah", "yup"]:
if (await userdb.find_one({"userid": user.id})):
udata = (await userdb.find_one({"userid": user.id}))
if bet > udata["economy"]["wallet"]:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"{user.display_name} doesn't have that much money in their wallet!{sep}*(lol poor fella)*",
colour="#FF0000"
)
return await ctx.reply(embed=embed)
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"Flipping a coin for **\${bet:,}**... {sep}You now have `${(await userdb.find_one({'userid': user.id}))['economy']['wallet']-bet:,}` in your wallet!",
media = "https://media.tenor.com/images/60b3d58b8161ad9b03675abf301e8fb4/tenor.gif",
colour="#00FF00"
)
await userdb.bulk_write([
pymongo.UpdateOne(
{"userid": user.id},
{"$inc": {"economy.wallet": -bet}}
),
pymongo.UpdateOne(
{"userid": ctx.author.id},
{"$inc": {"economy.wallet": -bet}}
)
])
await ctx.reply(embed=embed, content=user.mention)
if random.choice(['heads', 'tails']) == choice.lower():
await userdb.bulk_write([
pymongo.UpdateOne(
{"userid": ctx.author.id},
{"$inc": {"economy.wallet": bet*2}}
)
])
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"{ctx.author.mention} won **\${bet:,}**! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#00FF00"
)
return await ctx.reply(embed=embed)
else:
await userdb.bulk_write([
pymongo.UpdateOne(
{"userid": user.id},
{"$inc": {"economy.wallet": bet*2}}
)
])
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"{user.mention} won **\${bet:,}**! {sep}They now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in their wallet!",
colour="#00FF00"
)
return await msg.reply(embed=embed)
else:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"{user.display_name} doesn't exist! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#FF0000"
)
await ctx.reply(embed=embed)
elif msg.content.lower() in ["no", "n", "nah", "nope"]:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"Looks like {user.display_name} doesn't want to play with you. {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#FF0000"
)
return await ctx.reply(embed=embed)
else:
await ctx.send(msg.content)
except asyncio.TimeoutError:
embed = voltage.SendableEmbed(
title=ctx.author.display_name,
icon_url=ctx.author.display_avatar.url,
description=f"{user.display_name} didn't respond in time! {sep}You now have `${(await userdb.find_one({'userid': ctx.author.id}))['economy']['wallet']:,}` in your wallet!",
colour="#FF0000"
)
return await ctx.reply(embed=embed)

@eco.command(name="blackjack", aliases=["bj"], description="Play a game of blackjack!")
@limiter(7, on_ratelimited=lambda ctx, delay, *_1, **_2: ctx.send(f"You're on cooldown! Please wait `{round(delay, 2)}s`!"))
async def blackjack(ctx, bet:int=None):
if not bet or not str(bet).is_integer() or bet < 0:
if not bet or bet < 0:
return await ctx.reply("Please enter a valid bet!")
elif bet > (await userdb.find_one({"userid": ctx.author.id}))["economy"]["wallet"]:
embed = voltage.SendableEmbed(
Expand Down
1 change: 1 addition & 0 deletions cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async def purge(ctx, amount:int=10):
headers={"x-bot-token": config['TOKEN']},
json={"ids": ids}
)
await session.close()
embed = voltage.SendableEmbed(
description=f"# Purged!\nPurged {amount} messages in {round(time.time() - starttime, 2)}s!",
color="#00FF00",
Expand Down
34 changes: 25 additions & 9 deletions cogs/owner.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import voltage, asyncio, random, time, psutil, pymongo, json, datetime, io, contextlib, requests, string, os, sys, pilcord
import voltage, asyncio, random, time, psutil, pymongo, json, datetime, io, contextlib, requests, string, os, sys, pilcord, motor
from bson.son import SON
from voltage.ext import commands
from pymongo.mongo_client import MongoClient
Expand All @@ -7,7 +7,7 @@
with open("json/config.json", "r") as f:
config = json.load(f)

DBclient = MongoClient(config["MONGOURI"])
DBclient = motor.motor_asyncio.AsyncIOMotorClient(config['MONGOURI'])

db = DBclient["beta"]
userdb = db["users"]
Expand Down Expand Up @@ -228,7 +228,7 @@ async def servers(ctx):
@owner.command()
async def apu(ctx, user:voltage.User, *, prefix:str):
if ctx.author.id == "01FZB2QAPRVT8PVMF11480GRCD":
userdb.update_one({
await userdb.update_one({
"userid": user.id
}, {
"$push": {
Expand All @@ -242,7 +242,7 @@ async def apu(ctx, user:voltage.User, *, prefix:str):
@owner.command()
async def dpu(ctx, user:voltage.User, *, prefix:str):
if ctx.author.id == "01FZB2QAPRVT8PVMF11480GRCD":
userdb.update_one({
await userdb.update_one({
"userid": user.id
}, {
"$pull": {
Expand Down Expand Up @@ -278,7 +278,7 @@ async def addbadge(ctx, user:voltage.User, badge:int=None):
)
return await ctx.send(embed=embed)
elif get_badge(badge):
userdb.update_one(
await userdb.update_one(
{
"userid": user.id
},
Expand All @@ -302,7 +302,7 @@ async def removebadge(ctx, user:voltage.User, badge:int=None):
)
await ctx.send(embed=embed)
elif get_badge(badge):
userdb.update_one(
await userdb.update_one(
{
"userid": user.id
},
Expand All @@ -320,7 +320,7 @@ async def removebadge(ctx, user:voltage.User, badge:int=None):
async def give(ctx, user:voltage.User, amount:int):
if ctx.author.id == "01FZB2QAPRVT8PVMF11480GRCD":
i = 1
for _ in userdb.find_one({"userid": user.id})["notifications"]["inbox"]:
for _ in (await userdb.find_one({"userid": user.id}))["notifications"]["inbox"]:
i += 1
userdb.bulk_write([
pymongo.UpdateOne(
Expand All @@ -340,9 +340,9 @@ async def give(ctx, user:voltage.User, amount:int):
{
"$set": {
f"notifications.inbox.{str(i)}": {
"message":f"You've recieved {amount:,} coins as per compensation for being affected by a bug! Use `m!balance` to check your balance.",
"message":f"You've recieved {amount:,}!",
"date": time.time(),
"title": "You've been affected by a bug!",
"title": "You've been given some coins!",
"type": "admin",
"read": False
}
Expand All @@ -354,5 +354,21 @@ async def give(ctx, user:voltage.User, amount:int):
else:
await ctx.reply("Not owner, cant use this.")

@owner.command()
async def betamsg(ctx):
if ctx.author.id == "01FZB2QAPRVT8PVMF11480GRCD":
embed = voltage.SendableEmbed(
title="Beta Message",
description="React with **👍** to enable beta testing!",
colour="#FF0000"
)
msg = await ctx.send(embed=embed, interactions={"reactions":['👍'], "restrict_reactions": True})
with open("json/data.json", "r") as f:
data = json.load(f)
data["BETA_ID"] = str(msg.id)
with open("json/data.json", "w") as f:
json.dump(data, f, indent=2)
else:
await ctx.reply("Not owner, cant use this.")

return owner
39 changes: 22 additions & 17 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,24 +438,29 @@ async def snitch(ctx):

@utility.command()
async def confirm(ctx):
embed = voltage.SendableEmbed(
title="Confirm!",
description="React with ✅ to confirm!",
colour="#516BF2",
icon_url=ctx.author.display_avatar.url
)
ms = await ctx.send(embed=embed, interactions={"reactions": ["✅"], "restrict_reactions": False})
try:
async with aiohttp.ClientSession() as session:
async with session.post(
url=f"https://api.revolt.chat/channels/{ctx.channel.id}/messages",
headers={"x-bot-token": config['TOKEN']},
json={
"content": "Do you confirm?",
"interactions": {
"reactions": [
"01HPX2NV8VVPYKFV0YYADQH33X"
]
}
}
) as response:
result = await response.json()

except Exception as e:
return e
def check(message, user, reaction):
#print(message.id == ms.id)
#print(user == ctx.author.id)
#print(reaction == "✅")
return ms.id == message.id and user == ctx.author.id and reaction == "✅"
await client.wait_for("message_react", check=check, timeout=15.0)
embed = voltage.SendableEmbed(
title="Confirmed!",
description="You have confirmed!",
colour="#00FF00",
icon_url=ctx.author.display_avatar.url
)
return await ms.edit(embed=embed)
except asyncio.TimeoutError:
return await ctx.send("Confirmation timed out!")

@utility.command(
name="familyfriendly",
Expand Down
Loading

0 comments on commit 65cb5c5

Please sign in to comment.