Initial commit.
This commit is contained in:
0
cogs/__init__.py
Normal file
0
cogs/__init__.py
Normal file
30
cogs/channel.py
Normal file
30
cogs/channel.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
class Channel(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.slash_command(name="clear_channel",
|
||||||
|
description="Permanently delete all messages in a channel",
|
||||||
|
guild_ids=[681414775468589180])
|
||||||
|
@commands.has_permissions(manage_messages=True)
|
||||||
|
async def clear_channel(self, ctx: discord.ApplicationContext):
|
||||||
|
progress = await ctx.respond("Deleting all messages in this channel...", ephemeral=True)
|
||||||
|
channel = ctx.channel
|
||||||
|
|
||||||
|
# Fetch all messages in the channel
|
||||||
|
async for message in channel.history(limit=None):
|
||||||
|
try:
|
||||||
|
await message.delete()
|
||||||
|
except discord.Forbidden:
|
||||||
|
await ctx.send("I do not have permission to delete messages.")
|
||||||
|
return
|
||||||
|
except discord.HTTPException:
|
||||||
|
await ctx.send("Failed to delete a message.")
|
||||||
|
return
|
||||||
|
|
||||||
|
await progress.edit(content="✔ All messages deleted successfully! ✔")
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Channel(bot))
|
||||||
15
cogs/hello.py
Normal file
15
cogs/hello.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
class Hello(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.slash_command(name="hello",
|
||||||
|
description="Say hi to the bot!",
|
||||||
|
guild_ids=[681414775468589180])
|
||||||
|
async def hello(self, ctx: discord.ApplicationContext):
|
||||||
|
await ctx.respond("Hello there!")
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Hello(bot))
|
||||||
13
cogs/ping.py
Normal file
13
cogs/ping.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
class Ping(commands.Cog):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
@commands.slash_command(name="ping", description="Ping the bot")
|
||||||
|
async def ping(self, ctx: discord.ApplicationContext):
|
||||||
|
await ctx.respond("🏓 Pong!")
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Ping(bot))
|
||||||
75
main.py
Normal file
75
main.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import os
|
||||||
|
import discord
|
||||||
|
import asyncio
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from pathlib import Path
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.progress import track
|
||||||
|
from rich.panel import Panel
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
TOKEN = os.getenv("BOT_TOKEN")
|
||||||
|
DEV_GUILD_ID = int(os.getenv("DEV_GUILD_ID"))
|
||||||
|
|
||||||
|
# Initialize the console for rich output
|
||||||
|
console = Console()
|
||||||
|
|
||||||
|
# Set up intents for the bot
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.message_content = True
|
||||||
|
|
||||||
|
# Create the bot instance
|
||||||
|
bot = discord.Bot(intents=intents)
|
||||||
|
|
||||||
|
# Cog directory and Loading handling
|
||||||
|
COG_PATH = Path(__file__).resolve().parent / "cogs"
|
||||||
|
cogs_available = {}
|
||||||
|
loaded_cog_modules = {}
|
||||||
|
|
||||||
|
for file in COG_PATH.iterdir():
|
||||||
|
if file.suffix == ".py" and not file.name.startswith("__"):
|
||||||
|
cog_name = file.stem
|
||||||
|
cogs_available[cog_name] = file
|
||||||
|
|
||||||
|
async def load_cogs():
|
||||||
|
if not cogs_available:
|
||||||
|
console.log("[yellow]⚙️ No cogs available to load...[/yellow]")
|
||||||
|
return
|
||||||
|
|
||||||
|
if not COG_PATH.exists():
|
||||||
|
console.log(f"[red]❌ Cogs directory not found at {COG_PATH}[/red]")
|
||||||
|
return
|
||||||
|
|
||||||
|
console.print(Panel.fit("🔌 [bold]Loading Cogs[/bold]", style="cyan"))
|
||||||
|
|
||||||
|
for cog in track(cogs_available, description="Loading Cogs..."):
|
||||||
|
module_path = f"cogs.{cog}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
bot.load_extension(module_path)
|
||||||
|
loaded_cog_modules[cog] = module_path
|
||||||
|
console.log(f"[green]✔ Loaded:[/] Cog - {cog}")
|
||||||
|
except Exception as e:
|
||||||
|
console.log(f"[red]✖ Failed to load:[/] Cog - {cog}")
|
||||||
|
console.log(f"[red]{type(e).__name__}: {e}[/]")
|
||||||
|
|
||||||
|
# Bot Event Handlers
|
||||||
|
@bot.event
|
||||||
|
async def on_ready():
|
||||||
|
await load_cogs()
|
||||||
|
await bot.sync_commands()
|
||||||
|
console.log("[blue]🔁 Synced slash commands[/blue]")
|
||||||
|
console.rule(f"[bold green]✅ Bot Ready — Logged in as {bot.user}[/]")
|
||||||
|
console.print(f"ID: {bot.user.id}")
|
||||||
|
|
||||||
|
# Main Loop
|
||||||
|
if __name__ == "__main__":
|
||||||
|
async def main():
|
||||||
|
# Load cogs before the bot starts
|
||||||
|
#await load_cogs()
|
||||||
|
|
||||||
|
# Start the bot
|
||||||
|
await bot.start(TOKEN)
|
||||||
|
|
||||||
|
# Run the main loop
|
||||||
|
asyncio.run(main())
|
||||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
dotenv~=0.9.9
|
||||||
|
python-dotenv~=1.1.0
|
||||||
|
rich~=13.9.4
|
||||||
|
py-cord~=2.6.1
|
||||||
Reference in New Issue
Block a user