-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil_database.py
118 lines (90 loc) · 4.43 KB
/
util_database.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import motor.motor_asyncio as db_client, os
myclient = db_client.AsyncIOMotorClient(os.getenv('MONGO'))
# level + insult + music + ai + log
mycol2 = myclient["utils"]["nodeports"]
async def add_database2(server_id: int):
data = {
"guild": server_id,
"prefix": "-",
"bot_master_role": 0,
"bot_dj_role": 0,
"bot_dj_channel": 0,
"ai_mode": "",
"ai_rate": 1,
"ai_mention": True,
"log_mode": False, # social credit system
"log_notify_mode": "", # social credit system: dm, ephemeral
"log_notify_gearbot": "", # dm, ephemeral
"log_delete_msg": False, # requires manage messages
"log_channel": 0,
"insult_module": True,
"insult_default": True,
"xp_module": False,
"xp_troll": True,
"xp_channel_mode": False,
"xp_rate": 1,
"xp_cooldown": 60,
"channels": [],
"xp_roles": [],
"xp_messages": [],
"roasts": [],
"players": []
}
await mycol2.insert_one(data)
return data
async def fetch_database2(server_id: int):
return await mycol2.find_one({"guild":server_id})
async def get_database2(server_id: int):
db = await fetch_database2(server_id)
if db: return db
return await add_database2(server_id)
async def set_dj_role_db(server_id: int, role_id):
await mycol2.update_one({"guild":server_id}, {"$set": {"bot_dj_role": role_id}})
async def set_dj_channel_db(server_id: int, channel_id):
await mycol2.update_one({"guild":server_id}, {"$set": {"bot_dj_channel": channel_id}})
async def set_insult(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"insult_module": b}})
async def set_xp(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"xp_module": b}})
async def set_cooldown(server_id: int, b):
await mycol2.update_one({"guild":server_id}, {"$set": {"xp_cooldown": b}})
async def set_rate(server_id: int, b):
await mycol2.update_one({"guild":server_id}, {"$set": {"xp_rate": b}})
async def set_troll_mode(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"xp_troll": b}})
async def push_insult(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$push": {"roasts": data}})
async def pull_insult(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$pull": {"roasts": data}})
async def push_xp_msg(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$push": {"xp_messages": data}})
async def pull_xp_msg(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$pull": {"xp_messages": data}})
async def push_role(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$push": {"xp_roles": dict(data)}})
async def pull_role(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$pull": {"xp_roles": dict(data)}})
async def push_channel(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$push": {"channels": dict(data)}})
async def pull_channel(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$pull": {"channels": dict(data)}})
async def set_rank_channel(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$set": {"bot_rank_channel": data}})
async def set_prefix(server_id: int, p):
await mycol2.update_one({"guild":server_id}, {"$set": {"prefix": p}})
async def set_master_role(server_id: int, data):
await mycol2.update_one({"guild":server_id}, {"$set": {"bot_master_role": data}})
async def set_ai_mode(server_id: int, b):
await mycol2.update_one({"guild":server_id}, {"$set": {"ai_mode": b}})
async def set_ai_rate(server_id: int, b):
await mycol2.update_one({"guild":server_id}, {"$set": {"ai_rate": b}})
async def set_ai_mention(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"ai_mention": b}})
async def set_log_mode(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"log_mode": b}})
async def set_log_delete_msg(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"log_delete_msg": b}})
async def set_log_channel(server_id: int, b: bool):
await mycol2.update_one({"guild":server_id}, {"$set": {"log_channel": b}})
async def set_log_notify(server_id: int, b):
await mycol2.update_one({"guild":server_id}, {"$set": {"log_notify_mode": b}})