first commit
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import asyncio
|
||||
import os
|
||||
from discord import Intents
|
||||
from discord.ext import commands
|
||||
from HiddenMap import DiscordToken
|
||||
|
||||
# Correct intents (DO NOT use Intents.all)
|
||||
intents = Intents.default()
|
||||
intents.message_content = True
|
||||
|
||||
# Create bot
|
||||
client = commands.Bot(command_prefix="!", intents=intents)
|
||||
client.remove_command("help")
|
||||
|
||||
|
||||
# Bot ready
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print("Successfully connected")
|
||||
print(f"Logged in as: {client.user}")
|
||||
|
||||
|
||||
# Load all modules
|
||||
async def load():
|
||||
# Load commands
|
||||
for filename in os.listdir("./Commands"):
|
||||
if filename.endswith(".py"):
|
||||
try:
|
||||
await client.load_extension(f"Commands.{filename[:-3]}")
|
||||
print(f"Loaded command: {filename}")
|
||||
except Exception as e:
|
||||
print(f"Failed to load command {filename}: {e}")
|
||||
|
||||
# Load events
|
||||
for filename in os.listdir("./Events"):
|
||||
if filename.endswith(".py"):
|
||||
try:
|
||||
await client.load_extension(f"Events.{filename[:-3]}")
|
||||
print(f"Loaded event: {filename}")
|
||||
except Exception as e:
|
||||
print(f"Failed to load event {filename}: {e}")
|
||||
|
||||
|
||||
# Sync command
|
||||
@client.command()
|
||||
async def sync(ctx):
|
||||
print("Starting sync...")
|
||||
|
||||
if ctx.author.id in [262672220260663297, 268494575780233216]:
|
||||
try:
|
||||
synced = await client.tree.sync()
|
||||
print(f"Synced {len(synced)} commands")
|
||||
await ctx.send(f"Synced {len(synced)} commands")
|
||||
except Exception as e:
|
||||
print(f"Sync failed: {e}")
|
||||
await ctx.send("Sync failed")
|
||||
else:
|
||||
await ctx.send("```You dont have the rights to use this command!```")
|
||||
|
||||
|
||||
@client.command()
|
||||
async def sync_current(ctx):
|
||||
print("Starting guild sync...")
|
||||
|
||||
if ctx.author.id in [262672220260663297, 268494575780233216]:
|
||||
try:
|
||||
synced = await client.tree.sync(guild=ctx.guild)
|
||||
print(f"Synced {len(synced)} commands to this server")
|
||||
await ctx.send(f" Synced {len(synced)} commands (this server only)")
|
||||
except Exception as e:
|
||||
print(f"Guild sync failed: {e}")
|
||||
await ctx.send(" Guild sync failed")
|
||||
else:
|
||||
await ctx.send("```You dont have the rights to use this command!```")
|
||||
|
||||
|
||||
# Slash command error handler
|
||||
@client.tree.error
|
||||
async def on_app_command_error(interaction, error):
|
||||
print(f"Slash command error: {error}")
|
||||
|
||||
|
||||
# Run bot
|
||||
async def main():
|
||||
async with client:
|
||||
await load()
|
||||
await client.start(DiscordToken.get_token())
|
||||
|
||||
|
||||
# Start program
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user