Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
✔️ Prism 1.3 - Part 2 ✔️
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin O'Brien committed Aug 17, 2020
1 parent b204f54 commit 3cc0d5b
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 80 deletions.
9 changes: 7 additions & 2 deletions assets/prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ async def on_message(message):

return

if message.content in gdb[str(message.guild.id)]["data"]["triggers"]:

await ctx.send(gdb[str(message.guild.id)]["data"]["triggers"][message.content])

# Leveling
if str(message.author.id) in db:

Expand Down Expand Up @@ -433,7 +437,7 @@ async def status_change():

def error(text):

embed = discord.Embed(description = f"<:rename_it:730915977742778368> \t **{text}**", color = 0xff0000)
embed = discord.Embed(description = f":x: \t **{text}**", color = 0xff0000)

return embed

Expand Down Expand Up @@ -543,7 +547,8 @@ class Constants:
"joinleave_channel": None,
"deleted_messages": [],
"last_updated": "Never",
"autorole": None
"autorole": None,
"triggers": {}
}
}

Expand Down
2 changes: 1 addition & 1 deletion commands/currency/bank.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def bank(self, ctx, bank: int = None):

c = 1

embed = discord.Embed(title = "The National List of Banks", description = f"Current provider: {user['bank']['data']['name']}." if user["bank"]["data"] else "", color = 0x126bf1)
embed = discord.Embed(title = "The National List of Banks", description = f"Change your bank with the `bank BANKID` command.\nCurrent provider: {user['bank']['data']['name']}." if user["bank"]["data"] else "Set your bank with the `bank BANKID` command.", color = 0x126bf1)

for bank in self.banks:

Expand Down
104 changes: 40 additions & 64 deletions commands/currency/deposit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,85 +18,61 @@ def __init__(self, bot):
@commands.command(aliases = ["dep"])
async def deposit(self, ctx, amount = None):

if not user:

return await ctx.send(embed = Tools.error("No user specified to pay."))

elif not amount:

return await ctx.send(embed = Tools.error("No amount specified to pay."))

user = Tools.getClosestUser(ctx, user)

if not user:

return await ctx.send(embed = Tools.error(f"I couldn't find that user; try again with more letters."))

elif user.id == ctx.author.id:

return await ctx.send(embed = Tools.error("No paying yourself. >:C"))

elif user.id == self.bot.user.id:

return await ctx.send(embed = Tools.error("I don't need your coins. thx doe :D"))

if not amount:

return await ctx.send(embed = Tools.error("No amount was specified to deposit."))

db = loads(open("db/users", "r").read())

try:
user = db[str(ctx.author.id)]

if not user["bank"]["data"]:

return await ctx.send(embed = Tools.error("You don't have a bank account, get one with the `bank` command."))

limit = int(user["bank"]["data"]["limit"].replace(",", ""))

if user["bank"]["balance"] == limit:

return await ctx.send(embed = Tools.error("You're bank is full."))

amount = int(amount)
if amount == "all":

if len(str(amount)) > 100:
amount = user["balance"]

return await ctx.send(embed = Tools.error("That is way too many coins."))
else:

elif amount <= 0:
try:

return await ctx.send(embed = Tools.error("Please enter a valid amount."))
amount = int(amount)

except:
except:

if amount != "all":
return await ctx.send(embed = Tools.error("That isn't a valid amount."))

return await ctx.send(embed = Tools.error("Please enter a valid amount."))
todeposit = 0

else:
if amount + user["bank"]["balance"] > limit:

amount = db[str(ctx.author.id)]["balance"]

if not str(user.id) in db:

return await ctx.send(embed = Tools.error(f"{user.name} doesn't have an account."))

elif db[str(ctx.author.id)]["balance"] < amount:
todeposit = limit - user["bank"]["balance"]

return await ctx.send(embed = Tools.error(f"You don't have that many coins in your account."))
else:

todeposit = amount

user["balance"] -= todeposit

user["bank"]["balance"] += todeposit

db[str(ctx.author.id)]["balance"] -= amount

db[str(user.id)]["balance"] += amount

open("db/users", "w").write(dumps(db, indent = 4))

embed = discord.Embed(title = f"{user.name} has been payed {amount} coins.", color = 0x126bf1)

embed.set_author(name = " | Balance Update", icon_url = self.bot.user.avatar_url)

embed.set_footer(text = f" | Transaction initiated by {ctx.author}.", icon_url = ctx.author.avatar_url)

try:

return await ctx.send(embed = embed)

except:

embed = discord.Embed(title = f"{user.name} has been payed your entire balance.", color = 0x126bf1)

embed.set_author(name = " | Balance Update", icon_url = self.bot.user.avatar_url)

embed.set_footer(text = f" | Transaction initiated by {ctx.author}.", icon_url = ctx.author.avatar_url)

return await ctx.send(embed = embed)

if len(str(todeposit)) > 5:

a = len(str(todeposit)) - 5

todeposit = str(todeposit[:-a]) + ".."

return await ctx.send(embed = discord.Embed(title = f"{todeposit} coins deposited to bank.", color = 0x126bf1))

# Link to bot
def setup(bot):
Expand Down
67 changes: 67 additions & 0 deletions commands/currency/withdraw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Prism Rewrite - Basic Command

# Modules
import discord
from json import loads, dumps

from assets.prism import Tools
from discord.ext import commands

# Main Command Class
class Withdraw(commands.Cog):

def __init__(self, bot):
self.bot = bot
self.desc = "Takes coins in your bank"
self.usage = "withdraw [amount]"

@commands.command(aliases = ["wd"])
async def withdraw(self, ctx, amount = None):

if not amount:

return await ctx.send(embed = Tools.error("No amount was specified to withdraw."))

db = loads(open("db/users", "r").read())

user = db[str(ctx.author.id)]

if not user["bank"]["data"]:

return await ctx.send(embed = Tools.error("You don't have a bank account, get one with the `bank` command."))

if amount == "all":

amount = user["bank"]["balance"]

else:

try:

amount = int(amount)

except:

return await ctx.send(embed = Tools.error("That isn't a valid amount."))

if amount > user["bank"]["balance"]:

return await ctx.send(embed = Tools.error("You don't have that much money in your bank."))

user["balance"] += amount

user["bank"]["balance"] -= amount

open("db/users", "w").write(dumps(db, indent = 4))

if len(str(amount)) > 5:

a = len(str(amount)) - 5

amount = str(amount[:-a]) + ".."

return await ctx.send(embed = discord.Embed(title = f"{amount} coins withdrew from bank.", color = 0x126bf1))

# Link to bot
def setup(bot):
bot.add_cog(Withdraw(bot))
6 changes: 0 additions & 6 deletions commands/entertainment/fakeban.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ async def bban(self, ctx, user: discord.Member = None, *, reason: str = None):
elif user.id == ctx.author.id:

return await ctx.send(embed = Tools.error("Stop trying to ban yourself lmao"))

elif user.id == self.bot.user.id:

await ctx.send("If that's what you really want, then aight.")

return await ctx.guild.leave()

if reason:

Expand Down
93 changes: 93 additions & 0 deletions commands/entertainment/trigger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Prism Rewrite - Basic Command

# Modules
import discord
from json import loads, dumps

from assets.prism import Tools
from discord.ext import commands

# Main Command Class
class Trigger(commands.Cog):

def __init__(self, bot):
self.bot = bot
self.desc = "Text triggers for your server"
self.usage = "trigger [option] [trigger]"

@commands.command(aliases = ["triggers"])
async def trigger(self, ctx, option: str = None, *, trigger: str = None):

db = loads(open("db/guilds", "r").read())

_db = db[str(ctx.guild.id)]

if not option and not trigger:

triggers = ""

for trigger in _db["data"]["triggers"]:

triggers += f"`{trigger}`: {_db['data']['triggers'][trigger]}\n"

if not triggers:

triggers = "No triggers on this server."

embed = discord.Embed(title = "Server Triggers", description = triggers, color = 0x126bf1)

embed.set_author(name = " | Triggers", icon_url = self.bot.user.avatar_url)

embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url)

return await ctx.send(embed = embed)

elif not trigger:

return await ctx.send(embed = Tools.error("No option specified; valid options are `add`, and `delete`."))

elif option.lower() == "add":

if not "|" in trigger:

return await ctx.send(embed = Tools.error("Invalid trigger; `example: haha|no laughing!`."))

data = trigger.split("|")

trigger = data[0]

response = data[1]

if not response:

return await ctx.send(embed = Tools.error("Invalid trigger; `example: haha|no laughing!`."))

_db["data"]["triggers"][trigger] = response

embed = discord.Embed(title = f"Trigger #{len(_db['data']['triggers'])} saved.", color = 0x126bf1)

elif option.lower() == "delete":

if not trigger in _db["data"]["triggers"]:

return await ctx.send(embed = Tools.error("No such trigger exists."))

_db["data"]["triggers"].pop(trigger)

embed = discord.Embed(title = f"Trigger deleted.", color = 0x126bf1)

else:

embed = discord.Embed(title = "Invalid option.", description = "Valid options are `add`, and `delete`.", color = 0x126bf1)

embed.set_author(name = " | Triggers", icon_url = self.bot.user.avatar_url)

embed.set_footer(text = f" | Requested by {ctx.author}.", icon_url = ctx.author.avatar_url)

open("db/guilds", "w").write(dumps(db, indent = 4))

return await ctx.send(embed = embed)

# Link to bot
def setup(bot):
bot.add_cog(Trigger(bot))
2 changes: 1 addition & 1 deletion commands/misc/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def help(self, ctx, *, category = None):

except:

return await ctx.send(embed = Tools.error("Yea, that command randomly doesn't want to work today. (we are investigating it)"))
return await ctx.send(embed = Tools.error("That command is bugged (so stay tuned)."))

return await ctx.send(embed = await self.embed(ctx, Tools.uppercase(category), prefix, commandClass))

Expand Down
4 changes: 1 addition & 3 deletions commands/moderation/ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async def ban(self, ctx, user: discord.Member = None, *, reason: str = None):

elif user.id == self.bot.user.id:

await ctx.send("If that's what you really want, then aight.")

return await ctx.guild.leave()
return await ctx.send(embed = Tools.error("You cannot ban me. >:)"))

if reason:

Expand Down
4 changes: 1 addition & 3 deletions commands/moderation/kick.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ async def kick(self, ctx, user: discord.Member = None, *, reason: str = None):

elif user.id == self.bot.user.id:

await ctx.send("If that's what you really want, then aight.")

return await ctx.guild.leave()
return await ctx.send(embed = Tools.error("You cannot kick me. >:)"))

if reason:

Expand Down

0 comments on commit 3cc0d5b

Please sign in to comment.