-
Notifications
You must be signed in to change notification settings - Fork 0
/
configs.py
61 lines (49 loc) · 1.89 KB
/
configs.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
import asyncio
from datetime import datetime
import os
import json
import motor.motor_asyncio as motor
from dotenv import load_dotenv
def get_prefix(ctx):
try:
return prefixes[str(ctx.guild.id)]
except:
return defaultPrefix
load_dotenv()
discordToken = os.getenv("DISCORD_TOKEN")
steamToken = os.getenv("STEAM_WEB_API_KEY")
mongoConnectionURL = os.getenv("MONGO_CLUSTER")
googleToken = os.getenv("GOOGLE_API_KEY")
redditClientID = os.getenv("REDDIT_CLIENT_ID")
redditClientSecret = os.getenv("REDDIT_CLIENT_SECRET")
redditScriptName = os.getenv("REDDIT_SCRIPT_NAME")
botColor = {
"Spring Bud": 0xAFFF00,
"Yellow Green": 0x95C728,
"Lime Green": 0x4CC936,
"Sky Blue": 0x1BE7FF,
"Orange": 0xF08700,
}
prefixFile = "./prefixes.json"
prefixes = json.load(open(prefixFile, "r"))
cogsDir = "cogs"
defaultPrefix = "!"
CSEid = "49fac5d937f302021"
cluster = motor.AsyncIOMotorClient(mongoConnectionURL)
serverSettingsCollection = cluster["server"]["settings"]
async def make_blackList(col):
guilds= col.find(projection={"_id": True, "blacklisted": True, "disabled_commands": True})
blacklistedTextChannel = {}
disabledCommandsDict = {}
try:
async for guild in guilds:
blacklistedTextChannel[int(guild["_id"])] = [int(channel) for channel in guild["blacklisted"]]
disabledCommandsDict[int(guild["_id"])] = [cmd for cmd in guild["disabled_commands"]]
except Exception as e:
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(f"{now}: configs.make_blacklist() {e}")
return blacklistedTextChannel, disabledCommandsDict
blacklistedTextChannel, disabledCommandsDict = asyncio.get_event_loop().run_until_complete(make_blackList(serverSettingsCollection))
absDir = os.path.abspath(os.path.dirname(__file__))
if __name__ == "__main__":
print(absDir)