This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
64 lines (47 loc) · 1.68 KB
/
bot.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
#!/usr/bin/python3
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
import server
import logging
logger = logging.getLogger(__name__)
def setup_logger() -> None:
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter(
"%(asctime)s - %(levelname)s - %(message)s", "%Y-%m-%d %I:%M:%S %p %Z"
)
file_handler = logging.FileHandler("Logs/Bot.log")
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
class IllimitableBot(commands.Bot):
def __init__(self, command_prefix, **options):
super().__init__(command_prefix, **options)
self.load_cogs()
def load_cogs(self):
for filename in os.listdir("cogs"):
# Loop through the "cog" directory and load all the cogs
if filename.endswith(".py"):
extension = f"cogs.{filename[:-3]}"
self.load_extension(extension)
print(f"Extension {extension} Loaded Successfully.")
async def on_message(self, message):
if message.channel.type == discord.ChannelType.news:
await message.publish()
await self.process_commands(message)
async def on_ready(self):
await self.change_presence(
status=discord.Status.online, activity=discord.Game("Game of Life")
)
print(f"Bot {self.user} is connected to Discord and ready to roll!")
def main():
setup_logger()
logger.debug("Illimitable Bot (Re)Started")
bot = IllimitableBot(command_prefix=".")
server.alive()
# load_dotenv()
# bot.run(os.getenv("TOKEN"))
token = os.environ.get("TOKEN")
bot.run(token)
if __name__ == "__main__":
main()