-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
29 lines (25 loc) · 915 Bytes
/
bot.py
File metadata and controls
29 lines (25 loc) · 915 Bytes
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
import discord
from console_controller import ConsoleController
from dotenv import load_dotenv
import os
class ConsoleBot(discord.Client):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.controller = ConsoleController(self)
async def on_ready(self):
try:
print(f"Logged in as {self.user}")
await self.controller.run_interface()
except Exception as e:
print(f"An error occurred: {e}")
finally:
await self.close()
def run_bot():
load_dotenv() # Load environment variables from .env
intents = discord.Intents.default()
intents.members = True # Ensure you can read member information
intents.message_content = True # Ensure you can read message content
bot = ConsoleBot(intents=intents)
bot.run(os.getenv("DISCORD_TOKEN"))
if __name__ == "__main__":
run_bot()