Add src/SuperBot.py
This commit is contained in:
parent
f545f1bdbe
commit
436c8c104a
1 changed files with 54 additions and 0 deletions
54
src/SuperBot.py
Normal file
54
src/SuperBot.py
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import os
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands, tasks
|
||||||
|
import asyncio
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
prefix = "m!"
|
||||||
|
|
||||||
|
|
||||||
|
bot = commands.Bot(command_prefix=prefix, intents=discord.Intents.all())
|
||||||
|
|
||||||
|
|
||||||
|
@bot.slash_command(name="test", description="test")
|
||||||
|
async def test(ctx):
|
||||||
|
await ctx.respond("Hello")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.slash_command(name="ping", description="Bot latency")
|
||||||
|
async def ping(ctx):
|
||||||
|
await ctx.respond(f"Pong! Latency: {bot.latency * 1000:.2f} ms")
|
||||||
|
|
||||||
|
|
||||||
|
sys.path.append('../extensions')
|
||||||
|
|
||||||
|
for filename in os.listdir('./cogs'):
|
||||||
|
if filename.endswith('.py'):
|
||||||
|
try:
|
||||||
|
bot.load_extension(f"cogs.{filename[:-3]}")
|
||||||
|
print(f"Loaded extension: {filename[:-3]}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to load extension {filename[:-3]}: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_ready():
|
||||||
|
print(f'{bot.user.name} is online!')
|
||||||
|
await bot.wait_until_ready()
|
||||||
|
print(f"Active on {len(bot.guilds)} servers:")
|
||||||
|
for guild in bot.guilds:
|
||||||
|
print(f"- {guild.name} (ID: {guild.id})")
|
||||||
|
print(f'ID: {bot.user.id}')
|
||||||
|
print('-----------------------')
|
||||||
|
new_activity = discord.Activity(type=discord.ActivityType.watching,
|
||||||
|
name=f"Neon Genesis Evangelion")
|
||||||
|
await bot.change_presence(activity=new_activity)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
bot.run("TOKEN")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"An error occurred during startup: {e}")
|
Loading…
Add table
Add a link
Reference in a new issue