-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
40 lines (31 loc) · 1.08 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
#!/usr/local/bin/python3
import base64
import os
from os import environ
from sqlalchemy import select
from utils import utils
from disnake.ext.commands.bot import Bot
from weather import db
class MyBot(Bot):
async def on_ready(self):
print(f'{self.user.name} has connected to Discord!')
def main():
bot = MyBot(command_prefix='+')
token = environ["DISCORD_TOKEN"]
# db.Database.create_table(db.Database)
logger = utils.get_logger()
for file in os.listdir("./commands"):
if file.endswith(".py"):
extension = file[:-3]
try:
bot.load_extension(f"commands.{extension}")
print(f"Loaded extension '{extension}'")
logger.info(f"Loaded extension '{extension}'")
except Exception as e:
exception = f"{type(e).__name__}: {e}"
logger.info(
f"Failed to load extension {extension}\n{exception}")
print(f"Failed to load extension {extension}\n{exception}")
bot.run(token)
if __name__ == "__main__":
main()