Files
commands
utils
.gitignore
bot.py
config.json
README.md
requirements.txt
Code
8 534
bot.py
import discord
from discord.ext import commands
import os
import json
from dotenv import load_dotenv
load_dotenv()
with open('config.json', 'r') as f:
config = json.load(f)
intents = discord.Intents.default()
intents.message_content = True
intents.guilds = True
intents.members = True
bot = commands.Bot(command_prefix=config['prefix'], intents=intents, help_command=None)
@bot.event
async def on_ready():
print(f'✅ bot online!')
print(f'🤖 logged in as {bot.user.name}#{bot.user.discriminator}')
print(f'📊 serving {len(bot.guilds)} servers')
print(f'⚙️ prefix: {config["prefix"]}')
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandNotFound):
return
print(f'Error in command {ctx.command}: {error}')
embed = discord.Embed(
color=discord.Color.red(),
title='❌ Error',
description='An error occurred while executing this command.'
)
embed.timestamp = discord.utils.utcnow()
await ctx.reply(embed=embed)
@bot.event
async def on_error(event, *args, **kwargs):
print(f'Discord client error in {event}')
async def load_extensions():
await bot.load_extension('commands.steam')
async def main():
async with bot:
await load_extensions()
token = os.getenv('DEBUG_TOKEN') or os.getenv('TOKEN')
if not token:
print('❌ ERROR: No Discord token found in .env file')
return
await bot.start(token)
if __name__ == '__main__':
import asyncio
asyncio.run(main())