-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
68 lines (51 loc) · 1.41 KB
/
main.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
import os
import logging
import discord
from dotenv import load_dotenv
from discord.ext import commands
from pretty_help import PrettyHelp
from rich.logging import RichHandler
from Tools.utils import get_prefix
# getting environment variables
load_dotenv()
TOKEN = os.getenv("TOKEN")
OWNER = os.getenv("OWNER")
# setting up logging
FORMAT = "%(message)s"
logging.basicConfig(
level="INFO", format=FORMAT, datefmt="[%x]", handlers=[RichHandler()]
)
log = logging.getLogger("rich")
# Setting up Discord Intents
intents = discord.Intents.default()
intents.members = True
intents.presences = True
bot = commands.Bot(
command_prefix = get_prefix,
intents = intents,
case_insensitivity = True,
strip_after_prefix = True,
owner_id = OWNER,
help_command=PrettyHelp()
)
# Loading Cogs
for cog in os.listdir("Cogs"):
if cog.startswith("__pycache__"):
log.info("Skipping __pycache__ folder")
else:
try:
bot.load_extension(f"Cogs.{cog[:-3]}")
log.info(f"Loaded {cog[:-3]} ✅")
except Exception as e:
log.fatal(f"Failed to load {cog[:-3]}, error: {e}")
@bot.event
async def on_ready():
log.info(f"{bot.user} 🦅 is active now 😎")
await bot.change_presence(
activity = discord.Activity(
type = discord.ActivityType.watching,
name = "You 👁"
)
)
# Running the Bot
bot.run(TOKEN)