1
- from modules . bank_funcs import *
1
+ from base import EconomyBot
2
2
3
3
import discord
4
4
import asyncio
9
9
10
10
11
11
class Fun (commands .Cog ):
12
- def __init__ (self , client : commands . Bot ):
12
+ def __init__ (self , client : EconomyBot ):
13
13
self .client = client
14
+ self .bank = self .client .db .bank
14
15
15
16
@commands .command (aliases = ["cf" , "coinflip" ], usage = "<bet_on*: heads(H) or tails(T)> <amount*: integer>" )
16
17
@commands .guild_only ()
17
18
async def coin_flip (self , ctx , bet_on : str , amount : int ):
18
19
user = ctx .author
19
- await open_bank (user )
20
+ await self . bank . open_acc (user )
20
21
21
22
bet_on = "heads" if "h" in bet_on .lower () else "tails"
22
23
if not 500 <= amount <= 5000 :
23
24
return await ctx .reply ("You can only bet amount between 500 and 5000" , mention_author = False )
24
25
25
26
reward = round (amount / 2 )
26
- users = await get_bank_data (user )
27
+ users = await self . bank . get_acc (user )
27
28
if users [1 ] < amount :
28
29
return await ctx .reply ("You don't have enough money" , mention_author = False )
29
30
30
31
coin = ["heads" , "tails" ]
31
32
result = random .choice (coin )
32
33
33
34
if result != bet_on :
34
- await update_bank (user , - amount )
35
+ await self . bank . update_acc (user , - amount )
35
36
return await ctx .reply (f"Got { result } , you lost { amount :,} " , mention_author = False )
36
37
37
- await update_bank (user , + reward )
38
+ await self . bank . update_acc (user , + reward )
38
39
return await ctx .reply (f"Got { result } , you won { amount + reward :,} " , mention_author = False )
39
40
40
41
@commands .command (usage = "<amount*: integer" )
41
42
@commands .guild_only ()
42
43
async def slots (self , ctx : commands .Context , amount : int ):
43
44
user = ctx .author
44
- await open_bank (user )
45
+ await self . bank . open_acc (user )
45
46
if not 1000 <= amount <= 10000 :
46
47
return await ctx .reply ("You can only bet amount between 1000 and 10000" , mention_author = False )
47
48
48
- users = await get_bank_data (user )
49
+ users = await self . bank . get_acc (user )
49
50
if users [1 ] < amount :
50
51
return await ctx .reply ("You don't have enough money" , mention_author = False )
51
52
@@ -91,22 +92,22 @@ async def slots(self, ctx: commands.Context, amount: int):
91
92
s3 = slot [2 ]
92
93
if s1 == s2 == s3 :
93
94
reward = round (amount / 2 )
94
- await update_bank (user , + reward )
95
+ await self . bank . update_acc (user , + reward )
95
96
content = f"{ user .mention } Jackpot! you won { amount + reward :,} "
96
97
elif s1 == s2 or s2 == s3 or s1 == s3 :
97
98
reward = round (amount / 4 )
98
- await update_bank (user , + reward )
99
+ await self . bank . update_acc (user , + reward )
99
100
content = f"{ user .mention } GG! you only won { amount + reward :,} "
100
101
else :
101
- await update_bank (user , - amount )
102
+ await self . bank . update_acc (user , - amount )
102
103
content = f"{ user .mention } You lost { amount :,} "
103
104
104
105
return await msg .edit (content = content , embed = em )
105
106
106
107
@commands .command (usage = "<amount*: integer> <bet_on: integer>" )
107
108
async def dice (self , ctx , amount : int , bet_on : int = 6 ):
108
109
user = ctx .author
109
- await open_bank (user )
110
+ await self . bank . open_acc (user )
110
111
111
112
rdice = [1 , 2 , 3 , 4 , 5 , 6 ]
112
113
if bet_on not in rdice :
@@ -115,17 +116,17 @@ async def dice(self, ctx, amount: int, bet_on: int = 6):
115
116
if not 1000 <= amount <= 5000 :
116
117
return await ctx .reply ("You can only bet amount between 1000 and 5000" , mention_author = False )
117
118
118
- users = await get_bank_data (user )
119
+ users = await self . bank . get_acc (user )
119
120
if users [1 ] < amount :
120
121
return await ctx .reply ("You don't have enough money" , mention_author = False )
121
122
122
123
rand_num = random .choice (rdice )
123
124
if rand_num != bet_on :
124
- await update_bank (user , - amount )
125
+ await self . bank . update_acc (user , - amount )
125
126
return await ctx .reply (f"Got { rand_num } , you lost { amount :,} " , mention_author = False )
126
127
127
128
reward = round (amount / 2 )
128
- await update_bank (user , + reward )
129
+ await self . bank . update_acc (user , + reward )
129
130
await ctx .reply (f"Got { rand_num } , you won { amount + reward :,} " , mention_author = False )
130
131
131
132
0 commit comments