11# Modules
22import discord
3- from json import loads , dumps
3+ from random import randint
44
5+ from json import loads , dumps
56from discord .ext import commands
6- from random import randint , choice
77
88from assets .prism import Tools , Constants , Cooldowns
99
@@ -12,48 +12,23 @@ class Work(commands.Cog):
1212
1313 def __init__ (self , bot ):
1414 self .bot = bot
15- self .desc = "Work for some hard, cold cash "
15+ self .desc = "Work for some coins "
1616 self .usage = "work"
1717
18- self .problems = [
19- {
20- "equation" : "5 + 5" ,
21- "answer" : "10"
22- },
23- {
24- "equation" : "16 + 5" ,
25- "answer" : "21"
26- },
27- {
28- "equation" : "9 + 10" ,
29- "answer" : "19"
30- },
31- {
32- "equation" : "(5 + 5) / 2" ,
33- "answer" : "5"
34- },
35- {
36- "equation" : "5x - 5 = 10; what is x?" ,
37- "answer" : "3"
38- },
39- {
40- "equation" : "((9 x 9) - 1 + 20) / 100" ,
41- "answer" : "1"
42- }
43- ]
44-
4518 @commands .command ()
4619 async def work (self , ctx ):
4720
4821 if Cooldowns .on_cooldown (ctx , "work" ):
4922
5023 return await ctx .send (embed = Cooldowns .cooldown_text (ctx , "work" ))
51-
52- failed_earn = randint (20 , 80 )
53-
54- problem = choice (self .problems )
5524
56- bot_msg = await ctx .send (f"You are now working; solve the equation: `{ problem ['equation' ]} `." )
25+ n1 = randint (1 , 100 )
26+
27+ n2 = randint (1 , 100 )
28+
29+ answer = n1 + n2
30+
31+ bot_msg = await ctx .send (f"You are now working; solve the equation: `{ n1 } + { n2 } `." )
5732
5833 db = loads (open ("db/users" , "r" ).read ())
5934
@@ -66,12 +41,14 @@ def check(m):
6641 message = await self .bot .wait_for ("message" , check = check , timeout = 5 )
6742
6843 except :
69-
70- db [str (ctx .author .id )]["balance" ] += failed_earn
44+
45+ earnings = randint (20 , 100 )
46+
47+ db [str (ctx .author .id )]["balance" ] += earnings
7148
7249 open ("db/users" , "w" ).write (dumps (db , indent = 4 ))
7350
74- return await ctx .send (embed = Tools .error (f"You didn't respond fast enough; but you still earned { failed_earn } coins." ))
51+ return await ctx .send (embed = Tools .error (f"You didn't respond fast enough; but you still earned { earnings } coins." ))
7552
7653 try :
7754
@@ -81,23 +58,25 @@ def check(m):
8158
8259 pass
8360
84- if not message .content .lower () == problem [ " answer" ] :
61+ if not message .content .lower () == str ( answer ) :
8562
86- db [str (ctx .author .id )]["balance" ] += failed_earn
63+ earnings = randint (20 , 100 )
64+
65+ db [str (ctx .author .id )]["balance" ] += earnings
8766
8867 open ("db/users" , "w" ).write (dumps (db , indent = 4 ))
8968
90- await ctx .send (embed = Tools .error (f"You messed up at work; but you still earned { failed_earn } coins." ))
69+ await ctx .send (embed = Tools .error (f"You messed up at work; but you still earned { earnings } coins." ))
9170
9271 return await Cooldowns .set_cooldown (ctx , "work" , 600 )
9372
94- good_earnings = randint (200 , 450 )
73+ reward = randint (200 , 450 )
9574
96- db [str (ctx .author .id )]["balance" ] += good_earnings
75+ db [str (ctx .author .id )]["balance" ] += reward
9776
9877 open ("db/users" , "w" ).write (dumps (db , indent = 4 ))
9978
100- embed = discord .Embed (title = f"Good job, you went to work and earned { good_earnings } coins." , color = 0x126bf1 )
79+ embed = discord .Embed (title = f"Good job, you went to work and earned { reward } coins." , color = 0x126bf1 )
10180
10281 embed .set_author (name = " | Work" , icon_url = self .bot .user .avatar_url )
10382
0 commit comments