Files
cogs
utils
bot.py
config.py
requirements.txt
Code
9 483
bot.py
import discord
from discord.ext import commands
import os
import asyncio
from dotenv import load_dotenv
from config import PREFIX
load_dotenv()
TOKEN = os.getenv("<redacted>")
if not TOKEN or TOKEN == "<redacted>"
raise ValueError("<redacted>")
intents = discord.Intents.all()
bot = commands.Bot(
command_prefix=PREFIX,
intents=intents,
help_command=commands.DefaultHelpCommand(),
case_insensitive=True,
)
@bot.command(name="ping", help="Check bot latency")
async def ping(ctx: commands.Context):
await ctx.send(f"Pong! `{round(bot.latency * 1000)}ms`")
@bot.command(name="servers", help="List servers the bot is in")
@commands.is_owner()
async def servers(ctx: commands.Context):
guilds = "\n".join(f"{g.name} ({g.id}) — {g.member_count} members" for g in bot.guilds)
await ctx.send(f"**Servers ({len(bot.guilds)}):**\n{guilds}")
async def main():
async with bot:
for filename in ["cogs.moderation", "cogs.events"]:
try:
await bot.load_extension(filename)
print(f"Loaded {filename}")
except Exception as e:
print(f"Failed to load {filename}: {e}")
await bot.start("<redacted>")
if __name__ == "__main__":
asyncio.run(main())