-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.py
58 lines (45 loc) · 1.6 KB
/
index.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
from dotenv import load_dotenv
import os
import asyncio
from pymongo import MongoClient
from urllib.parse import quote_plus
import discord
from discord.ext import commands
load_dotenv()
cogs = ["cog.basic", "cog.valve", "cog.database", "cog.automation"]
class Bot(commands.Bot):
def __init__(self):
super().__init__(command_prefix="s!", intents=discord.Intents.default())
async def startup(self):
await bot.wait_until_ready()
if os.getenv("DEBUG") == "true":
print("Debug mode on: syncing only to Steam Servers Support")
await bot.tree.sync(guild=discord.Object(441425708896747532))
else:
print("Production mode")
await bot.tree.sync()
print("Successfully synced commands")
print(f"Connected as {bot.user}")
async def setup_hook(self):
for extension in cogs:
try:
await bot.load_extension(extension)
print(f"Loaded {extension}")
except Exception as e:
print(f"Failed to load {extension}")
print(f"[ERROR] {e}")
self.loop.create_task(self.startup())
bot = Bot()
bot.db = MongoClient("mongodb://%s:%s@%s/%s" % (
quote_plus(os.getenv('MONGO_USERNAME')),
quote_plus(os.getenv('MONGO_PASSWORD')),
os.getenv('MONGO_HOST'),
os.getenv('MONGO_DATABASE')))[os.getenv('MONGO_DATABASE')]
@bot.event
async def on_ready():
print(f'Logged in with '+str(len(bot.guilds))+" guilds")
if __name__ == "__main__":
try:
bot.run(os.getenv("TOKEN"))
except KeyboardInterrupt:
bot.close()