Files
cogs
bot.py
config.json
README.md
requirements.txt
Code
9 630
bot.py
import discord
from discord.ext import commands
import json
import os
from dotenv import load_dotenv
load_dotenv()
class SupportBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
super().__init__(command_prefix='!', intents=intents)
self.config = self.load_config()
def load_config(self):
with open('config.json', 'r') as f:
return json.load(f)
def save_config(self):
with open('config.json', 'w') as f:
json.dump(self.config, f, indent=4)
async def setup_hook(self):
await self.load_cogs()
try:
synced = await self.tree.sync()
print(f"Synced {len(synced)} global commands")
except Exception as e:
print(f"Failed to sync commands: {e}")
async def load_cogs(self):
cogs = ['cogs.tickets', 'cogs.welcome', 'cogs.admin', 'cogs.keywords']
for cog in cogs:
try:
await self.load_extension(cog)
print(f"Loaded {cog}")
except Exception as e:
print(f"Failed to load {cog}: {e}")
bot = SupportBot()
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
print(f'Bot ID: {bot.user.id}')
status_config = bot.config.get('status', {})
if status_config.get('enabled', False):
activity_type = status_config.get('type', 'playing')
activity_text = status_config.get('text', 'with tickets')
activity = None
if activity_type == 'playing':
activity = discord.Game(name=activity_text)
elif activity_type == 'watching':
activity = discord.Activity(type=discord.ActivityType.watching, name=activity_text)
elif activity_type == 'listening':
activity = discord.Activity(type=discord.ActivityType.listening, name=activity_text)
elif activity_type == 'streaming':
activity = discord.Streaming(name=activity_text, url=status_config.get('url', 'https://twitch.tv/'))
await bot.change_presence(activity=activity)
print('Bot is ready!')
print(f'Invite URL: https://discord.com/api/oauth2/authorize?client_id={bot.user.id}&permissions=8&scope=bot%20applications.commands')
bot.run(os.getenv('DISCORD_TOKEN'))