-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
44 lines (32 loc) · 1.13 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
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
DISCORD_TOKEN = os.getenv("BARISTA_TOKEN")
class Bot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
super().__init__(
command_prefix=commands.when_mentioned_or("!"),
intents=intents,
activity=discord.Game(name="💻 & ☕"),
)
async def on_ready(self):
print(f"Logged in as {self.user} (ID: {self.user.id})")
print("------")
async def setup_hook(self) -> None:
# Load cogs
for file in os.listdir(f"./cogs"):
if file.endswith(".py"):
extension = file[:-3]
try:
await bot.load_extension(f"cogs.{extension}")
print(f"Loaded extension '{extension}'")
except Exception as e:
exception = f"{type(e).__name__}: {e}"
print(f"Failed to load extension {extension}\n{exception}")
bot = Bot()
bot.run(DISCORD_TOKEN)