-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathapp.py
38 lines (31 loc) · 1.07 KB
/
app.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
# Built-In Libraries/Modules/Packages
from os import listdir
import traceback
# Third Party Libraries/Modules/Packages
from discord import ClientException, Intents
from discord.ext import commands
# User Defined Libraries/Modules/Packages
from cogs.utils.settings import Settings
intents = Intents.all()
# Initialsing bot with the prefix as `!` and
# removing the default Help Command
bot = commands.Bot(
command_prefix = "!",
help_command = None,
intents = intents
)
# To import and Load all Modules
def loadTheCogs(bot):
cogs_dir = "cogs"
# Getting all the python files present in `cogs` to a List
pythonFiles = [File for File in listdir(cogs_dir) if File.endswith(".py")]
for File in pythonFiles:
extension = File.replace('.py', '')
try:
bot.load_extension(cogs_dir + "." + extension)
except (ClientException, ModuleNotFoundError):
print(f'Failed to load extension {extension}.')
traceback.print_exc()
if __name__ == "__main__":
loadTheCogs(bot)
bot.run(Settings().SECRETS['DISCORD_TOKEN'])