-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (41 loc) · 1.26 KB
/
Copy pathmain.py
File metadata and controls
50 lines (41 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import discord
from discord.ext import commands
import os
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f'{bot.user} is now online!')
@bot.command()
async def load(ctx, extension):
"""Loads a cog."""
try:
bot.load_extension(f'cogs.{extension}')
await ctx.send(f'Cog {extension} loaded.')
except Exception as e:
await ctx.send(f'Failed to load cog: {e}')
@bot.command()
async def unload(ctx, extension):
"""Unloads a cog."""
try:
bot.unload_extension(f'cogs.{extension}')
await ctx.send(f'Cog {extension} unloaded.')
except Exception as e:
await ctx.send(f'Failed to unload cog: {e}')
@bot.command()
async def reload(ctx, extension):
"""Reloads a cog."""
try:
bot.reload_extension(f'cogs.{extension}')
await ctx.send(f'Cog {extension} reloaded.')
except Exception as e:
await ctx.send(f'Failed to reload cog: {e}')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
bot.run(TOKEN)