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 Release ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin O'Brien committed Aug 23, 2020
1 parent 3cc0d5b commit fcddab8
Show file tree
Hide file tree
Showing 50 changed files with 141 additions and 769 deletions.
140 changes: 51 additions & 89 deletions assets/prism.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Prism Rewrite - Main Prism File
# Contains all the functions that Prism needs to operate

# Last revision on August 7th, 2020.
# Prism Rewrite - Main File
# Contains all the functions (and events) that Prism needs to operate.

# Last revision on August 22nd, 2020.

# Modules
import discord
Expand All @@ -25,13 +24,12 @@ def create():
global bot

bot = commands.Bot(
command_prefix = Tools.get_prefix,
case_insensitive = True,
owner_ids = [
633185043774177280,
666839157502378014,
403375652755079170
]
command_prefix = Tools.get_prefix,
case_insensitive = True,
owner_ids = [
633185043774177280,
666839157502378014
]
)

bot.remove_command("help")
Expand Down Expand Up @@ -102,10 +100,6 @@ async def error_handler(ctx, error):

return await ctx.send(embed = Tools.error("Unknown (or invalid) argument provided."))

elif isinstance(error, commands.CommandNotFound):

return await ctx.send(embed = Tools.error("Sorry, but that command doesn't exist."))

elif isinstance(error, commands.NotOwner):

return await ctx.send(embed = Tools.error("This command is owner-only."))
Expand All @@ -124,9 +118,11 @@ async def error_handler(ctx, error):

pass

await ctx.send(embed = Tools.error("Sorry, an unknown error occured."))
await ctx.send(embed = discord.Embed(title = "Unexpected Error", description = "The command you just used generated an unexpected error.\nPrism has sent an automatic bug report about this problem.\n\nIn the meantime, try some of our other commands. :)", color = 0xFF0000))

return print(f"Command `{ctx.message.content}` used by `{ctx.author}`:" + "\n\t" + str(error))
base = ctx.message.content.split(" ")[0] if " " in ctx.message.content else ctx.message.content

return print(f"Command `{base}` used by `{ctx.author}`:" + "\n\t" + str(error))

async def on_message(message):

Expand All @@ -136,19 +132,6 @@ async def on_message(message):

return

elif not message.guild:

return await ctx.send("Sorry, Prism isn't available in private messages.")

elif ctx.id == 729760209223942165:

update = {
"jumpurl": message.jump_url,
"content": message.content
}

open("assets/res/plain-text/update.txt", "w+").write(dumps(update, indent = 4))

try:

prefix = gdb[str(message.guild.id)]["prefix"]
Expand All @@ -159,7 +142,7 @@ async def on_message(message):

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

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

# Leveling
if str(message.author.id) in db:
Expand All @@ -169,7 +152,7 @@ async def on_message(message):
current_level = levels["level"]
experience = levels["xp"]

required_xp = current_level * 1000
required_xp = current_level * 250

if experience >= required_xp:

Expand All @@ -189,25 +172,19 @@ async def on_message(message):

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

try:

if not Tools.ensure_command(gdb, message):

return

except:

pass
if not Tools.ensure_command(gdb, message):

return

if not str(user.id) in db:
elif not str(user.id) in db:

db[str(user.id)] = Constants.user_preset

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

elif Tools.has_flag(db, user, "blacklisted"):

return await ctx.send(embed = discord.Embed(title = "Sorry, but you are blacklisted from Prism.", color = 0x126bf1))
return await ctx.send(embed = discord.Embed(title = "Sorry, but you are blacklisted from Prism.", color = 0xFF0000))

elif db[str(user.id)]["balance"] < 0:

Expand Down Expand Up @@ -255,9 +232,9 @@ async def member_joined(member):

channel = bot.get_channel(int(db[str(member.guild.id)]["data"]["joinleave_channel"]))

embed = discord.Embed(description = f"Welcome to the server, {member.name}; hope you like it here.", color = 0x126bf1)
embed = discord.Embed(description = f"Welcome to {member.guild.name}, {member.name}.", color = 0x126bf1)

embed.set_author(name = " | Member Joined", icon_url = bot.user.avatar_url)
embed.set_author(name = " | Welcome", icon_url = bot.user.avatar_url)

embed.set_footer(text = f"Enjoy the server, {member.name}.", icon_url = member.avatar_url)

Expand Down Expand Up @@ -289,7 +266,7 @@ async def member_joined(member):

except:

db[str(member.guild.id)]["data"]["joinleave_channel"] = None
db[str(member.guild.id)]["data"]["autorole"] = None

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

Expand All @@ -305,7 +282,7 @@ async def member_left(member):

embed.set_author(name = " | Member Left", icon_url = bot.user.avatar_url)

embed.set_footer(text = f"Please nobody else leave :C.", icon_url = member.avatar_url)
embed.set_footer(text = f" | New user count: {len(member.guild.members)}", icon_url = member.guild.icon_url)

try:

Expand All @@ -319,7 +296,7 @@ async def member_left(member):

def message_delete(message):

if len(message.content) > 409:
if len(message.content) > 400:

return

Expand Down Expand Up @@ -375,18 +352,13 @@ async def status_change():

watching_names = [
"for p!help.",
"your mother.",
"the simpsons.",
"TV, so shush!",
f"{len(bot.users)} users.",
"YouTube.",
"my many fans.",
"your father. >_>",
"strange errors.",
"for p!rob.",
"for p!bomb",
"DmmD code.",
"commuter sleep.",
"p!help mod."
]

Expand All @@ -395,49 +367,38 @@ async def status_change():
"ROBLOX.",
"BeamNG.drive.",
"on an old Atari.",
"with my dev.",
"with my many friends.",
"with my friends.",
"GTA V.",
"on steam.",
"Unturned.",
"Terraria",
"with Dmot.",
"with Bob.",
"with your mum. HA!",
]

activity = choice(["watching", "playing"])

if activity == "watching":

while True:

try:

await bot.change_presence(status = discord.Status.idle, activity = discord.Activity(type = discord.ActivityType.watching, name = choice(watching_names)))

break
while True:

except:

await sleep(15)

else:

while True:

try:

try:

if activity == "watching":

await bot.change_presence(status = discord.Status.idle, activity = discord.Activity(type = discord.ActivityType.watching, name = choice(watching_names)))

else:

await bot.change_presence(status = discord.Status.idle, activity = discord.Activity(type = discord.ActivityType.playing, name = choice(playing_names)))
break
except:
await sleep(15)

break

except:

await sleep(15)

def error(text):

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

return embed

Expand All @@ -449,6 +410,12 @@ def bought(name, amount):

def getClosestUser(ctx, user, return_member = False):

if ctx.author.id == user.id:

user = ctx.author.id

user = str(user)

matcher = StringMatcher()

userdata = []
Expand Down Expand Up @@ -493,7 +460,7 @@ def getClosestUser(ctx, user, return_member = False):

if not matches:

return None
return await ctx.send(embed = Tools.error("Couldn't find that user."))

id = int(max(matches.items(), key = itemgetter(1))[0])

Expand Down Expand Up @@ -552,11 +519,6 @@ class Constants:
}
}

word_list = [
"discord", "cat", "dog", "minecraft", "hairnet", "code", "random", "snake", "screen",
"television", "lottery", "premium", "badge", "roblox", "mouse", "keyboard", "tablet"
]

class Cooldowns:

cooldowns = {}
Expand All @@ -567,7 +529,7 @@ async def set_cooldown(ctx, name, sec):

if "Cooldown Repellent" in db[str(ctx.author.id)]["data"]["inventory"]:

return
sec = round(sec / 2)

try:

Expand Down
4 changes: 3 additions & 1 deletion commands/currency/buy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from asyncio import sleep
from json import loads, dumps

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

# Main Command Class
class Buy(commands.Cog):
Expand Down Expand Up @@ -103,6 +103,8 @@ async def purchase(self, ctx, id, amount):

await ctx.send(embed = Tools.bought("Cooldown Repellent", 1))

Cooldowns.clear_cooldown(ctx.author)

self.save(db)

await sleep(duration)
Expand Down
2 changes: 1 addition & 1 deletion commands/currency/withdraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, bot):
self.desc = "Takes coins in your bank"
self.usage = "withdraw [amount]"

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

if not amount:
Expand Down
37 changes: 32 additions & 5 deletions commands/currency/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ def __init__(self, bot):
self.desc = "Work for some hard, cold cash"
self.usage = "work"

self.problems = [
{
"equation": "5 + 5",
"answer": "10"
},
{
"equation": "16 + 5",
"answer": "21"
},
{
"equation": "9 + 10",
"answer": "19"
},
{
"equation": "(5 + 5) / 2",
"answer": "5"
},
{
"equation": "5x - 5 = 10; what is x?",
"answer": "3"
},
{
"equation": "((9 x 9) - 1 + 20) / 100",
"answer": "1"
}
]

@commands.command()
async def work(self, ctx):

Expand All @@ -26,9 +53,9 @@ async def work(self, ctx):

failed_earn = randint(20, 80)

word = choice(Constants.word_list)
problem = choice(self.problems)

bot_msg = await ctx.send(f"You are now working; repeat the word ``{word}`` in this channel.")
bot_msg = await ctx.send(f"You are now working; solve the equation: `{problem['equation']}`.")

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

Expand All @@ -46,7 +73,7 @@ def check(m):

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

return await ctx.send(embed = Tools.error(f"You messed up at work; but you still earned {failed_earn} coins."))
return await ctx.send(embed = Tools.error(f"You didn't respond fast enough; but you still earned {failed_earn} coins."))

try:

Expand All @@ -56,7 +83,7 @@ def check(m):

pass

if not message.content.lower() == word:
if not message.content.lower() == problem["answer"]:

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

Expand All @@ -66,7 +93,7 @@ def check(m):

return await Cooldowns.set_cooldown(ctx, "work", 600)

good_earnings = randint(100, 275)
good_earnings = randint(200, 450)

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

Expand Down
Loading

0 comments on commit fcddab8

Please sign in to comment.