Files
__init__.py
__init__.py
bot.py
config.json
helpers.py
info.py
moderation.py
requirements.txt
voice.py
Code
9 832
/home/user/ModBot/bot.py
import discord
from discord.ext import commands
import os
import asyncio
from dotenv import load_dotenv
from utils.helpers import load_config
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
if not TOKEN:
raise ValueError("DISCORD_TOKEN not found in .env file. Please set it.")
config = load_config()
prefix = config.get("prefix", "!")
intents = discord.Intents.all()
bot = commands.Bot(command_prefix=prefix, intents=intents, help_command=None)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
print(f"Connected to {len(bot.guilds)} guild(s)")
print(f"Prefix: {prefix}")
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f"for {prefix}help"
)
)
async def load_extensions():
cogs = [
"cogs.moderation",
"cogs.voice",
"cogs.info"
]
for cog in cogs:
try:
await bot.load_extension(cog)
print(f"Loaded extension: {cog}")
except Exception as e:
print(f"Failed to load extension {cog}: {e}")
async def main():
async with bot:
await load_extensions()
await bot.start(TOKEN)
if __name__ == "__main__":
asyncio.run(main())