Files
cogs
utils
config.json
main.py
requirements.txt
Code
11 1,051
main.py
import discord
from discord.ext import commands
import os
import logging
from dotenv import load_dotenv
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
)
logger = logging.getLogger("StrikeTiers")
class StrikeTiersBot(commands.Bot):
def __init__(self):
intents = discord.Intents.all()
super().__init__(command_prefix="!", intents=intents, help_command=None)
async def setup_hook(self):
cogs = [
"cogs.verify",
"cogs.queue",
"cogs.results",
"cogs.leaderboard",
"cogs.admin",
]
for cog in cogs:
await self.load_extension(cog)
logger.info(f"Loaded cog: {cog}")
await self.tree.sync()
logger.info("Slash commands synced.")
async def on_ready(self):
logger.info(f"StrikeTiers bot ready! Logged in as {self.user} (ID: {self.user.id})")
await self.change_presence(
activity=discord.Activity(type=discord.ActivityType.watching, name="Tier Evaluations")
)
async def on_app_command_error(self, interaction: discord.Interaction, error: discord.app_commands.AppCommandError):
msg = "An error occurred while running this command."
if isinstance(error, discord.app_commands.MissingPermissions):
msg = "❌ You don't have permission to use this command."
elif isinstance(error, discord.app_commands.CommandOnCooldown):
msg = f"⏳ This command is on cooldown. Try again in {error.retry_after:.1f}s."
logger.error(f"Command error in {interaction.command}: {error}")
if not interaction.response.is_done():
await interaction.response.send_message(msg, ephemeral=True)
else:
await interaction.followup.send(msg, ephemeral=True)
bot = StrikeTiersBot()
bot.run(os.getenv("DISCORD_TOKEN"))