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

Commit fcddab8

Browse files
author
Benjamin O'Brien
committed
✨ Prism 1.3 Release ✨
1 parent 3cc0d5b commit fcddab8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+141
-769
lines changed

assets/prism.py

Lines changed: 51 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Prism Rewrite - Main Prism File
2-
# Contains all the functions that Prism needs to operate
3-
4-
# Last revision on August 7th, 2020.
1+
# Prism Rewrite - Main File
2+
# Contains all the functions (and events) that Prism needs to operate.
53

4+
# Last revision on August 22nd, 2020.
65

76
# Modules
87
import discord
@@ -25,13 +24,12 @@ def create():
2524
global bot
2625

2726
bot = commands.Bot(
28-
command_prefix = Tools.get_prefix,
29-
case_insensitive = True,
30-
owner_ids = [
31-
633185043774177280,
32-
666839157502378014,
33-
403375652755079170
34-
]
27+
command_prefix = Tools.get_prefix,
28+
case_insensitive = True,
29+
owner_ids = [
30+
633185043774177280,
31+
666839157502378014
32+
]
3533
)
3634

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

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

105-
elif isinstance(error, commands.CommandNotFound):
106-
107-
return await ctx.send(embed = Tools.error("Sorry, but that command doesn't exist."))
108-
109103
elif isinstance(error, commands.NotOwner):
110104

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

125119
pass
126120

127-
await ctx.send(embed = Tools.error("Sorry, an unknown error occured."))
121+
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))
128122

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

131127
async def on_message(message):
132128

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

137133
return
138134

139-
elif not message.guild:
140-
141-
return await ctx.send("Sorry, Prism isn't available in private messages.")
142-
143-
elif ctx.id == 729760209223942165:
144-
145-
update = {
146-
"jumpurl": message.jump_url,
147-
"content": message.content
148-
}
149-
150-
open("assets/res/plain-text/update.txt", "w+").write(dumps(update, indent = 4))
151-
152135
try:
153136

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

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

162-
await ctx.send(gdb[str(message.guild.id)]["data"]["triggers"][message.content])
145+
return await ctx.send(gdb[str(message.guild.id)]["data"]["triggers"][message.content])
163146

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

172-
required_xp = current_level * 1000
155+
required_xp = current_level * 250
173156

174157
if experience >= required_xp:
175158

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

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

192-
try:
193-
194-
if not Tools.ensure_command(gdb, message):
195-
196-
return
197-
198-
except:
199-
200-
pass
175+
if not Tools.ensure_command(gdb, message):
176+
177+
return
201178

202-
if not str(user.id) in db:
179+
elif not str(user.id) in db:
203180

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

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

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

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

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

@@ -255,9 +232,9 @@ async def member_joined(member):
255232

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

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

260-
embed.set_author(name = " | Member Joined", icon_url = bot.user.avatar_url)
237+
embed.set_author(name = " | Welcome", icon_url = bot.user.avatar_url)
261238

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

@@ -289,7 +266,7 @@ async def member_joined(member):
289266

290267
except:
291268

292-
db[str(member.guild.id)]["data"]["joinleave_channel"] = None
269+
db[str(member.guild.id)]["data"]["autorole"] = None
293270

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

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

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

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

310287
try:
311288

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

320297
def message_delete(message):
321298

322-
if len(message.content) > 409:
299+
if len(message.content) > 400:
323300

324301
return
325302

@@ -375,18 +352,13 @@ async def status_change():
375352

376353
watching_names = [
377354
"for p!help.",
378-
"your mother.",
379-
"the simpsons.",
380355
"TV, so shush!",
381356
f"{len(bot.users)} users.",
382357
"YouTube.",
383358
"my many fans.",
384-
"your father. >_>",
385-
"strange errors.",
386359
"for p!rob.",
387360
"for p!bomb",
388361
"DmmD code.",
389-
"commuter sleep.",
390362
"p!help mod."
391363
]
392364

@@ -395,49 +367,38 @@ async def status_change():
395367
"ROBLOX.",
396368
"BeamNG.drive.",
397369
"on an old Atari.",
398-
"with my dev.",
399-
"with my many friends.",
370+
"with my friends.",
400371
"GTA V.",
401372
"on steam.",
402373
"Unturned.",
374+
"Terraria",
403375
"with Dmot.",
404376
"with Bob.",
405-
"with your mum. HA!",
406377
]
407378

408379
activity = choice(["watching", "playing"])
409-
410-
if activity == "watching":
411380

412-
while True:
413-
414-
try:
415-
416-
await bot.change_presence(status = discord.Status.idle, activity = discord.Activity(type = discord.ActivityType.watching, name = choice(watching_names)))
417-
418-
break
381+
while True:
419382

420-
except:
421-
422-
await sleep(15)
423-
424-
else:
425-
426-
while True:
427-
428-
try:
429-
383+
try:
384+
385+
if activity == "watching":
386+
387+
await bot.change_presence(status = discord.Status.idle, activity = discord.Activity(type = discord.ActivityType.watching, name = choice(watching_names)))
388+
389+
else:
390+
430391
await bot.change_presence(status = discord.Status.idle, activity = discord.Activity(type = discord.ActivityType.playing, name = choice(playing_names)))
431-
432-
break
433-
434-
except:
435-
436-
await sleep(15)
392+
393+
break
394+
395+
except:
396+
397+
await sleep(15)
437398

438399
def error(text):
439400

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

442403
return embed
443404

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

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

413+
if ctx.author.id == user.id:
414+
415+
user = ctx.author.id
416+
417+
user = str(user)
418+
452419
matcher = StringMatcher()
453420

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

494461
if not matches:
495462

496-
return None
463+
return await ctx.send(embed = Tools.error("Couldn't find that user."))
497464

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

@@ -552,11 +519,6 @@ class Constants:
552519
}
553520
}
554521

555-
word_list = [
556-
"discord", "cat", "dog", "minecraft", "hairnet", "code", "random", "snake", "screen",
557-
"television", "lottery", "premium", "badge", "roblox", "mouse", "keyboard", "tablet"
558-
]
559-
560522
class Cooldowns:
561523

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

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

570-
return
532+
sec = round(sec / 2)
571533

572534
try:
573535

commands/currency/buy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from asyncio import sleep
55
from json import loads, dumps
66

7-
from assets.prism import Tools
87
from discord.ext import commands
8+
from assets.prism import Tools, Cooldowns
99

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

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

106+
Cooldowns.clear_cooldown(ctx.author)
107+
106108
self.save(db)
107109

108110
await sleep(duration)

commands/currency/withdraw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, bot):
1515
self.desc = "Takes coins in your bank"
1616
self.usage = "withdraw [amount]"
1717

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

2121
if not amount:

commands/currency/work.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,33 @@ def __init__(self, bot):
1717
self.desc = "Work for some hard, cold cash"
1818
self.usage = "work"
1919

20+
self.problems = [
21+
{
22+
"equation": "5 + 5",
23+
"answer": "10"
24+
},
25+
{
26+
"equation": "16 + 5",
27+
"answer": "21"
28+
},
29+
{
30+
"equation": "9 + 10",
31+
"answer": "19"
32+
},
33+
{
34+
"equation": "(5 + 5) / 2",
35+
"answer": "5"
36+
},
37+
{
38+
"equation": "5x - 5 = 10; what is x?",
39+
"answer": "3"
40+
},
41+
{
42+
"equation": "((9 x 9) - 1 + 20) / 100",
43+
"answer": "1"
44+
}
45+
]
46+
2047
@commands.command()
2148
async def work(self, ctx):
2249

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

2754
failed_earn = randint(20, 80)
2855

29-
word = choice(Constants.word_list)
56+
problem = choice(self.problems)
3057

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

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

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

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

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

5178
try:
5279

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

5784
pass
5885

59-
if not message.content.lower() == word:
86+
if not message.content.lower() == problem["answer"]:
6087

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

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

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

69-
good_earnings = randint(100, 275)
96+
good_earnings = randint(200, 450)
7097

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

0 commit comments

Comments
 (0)