-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
64 lines (49 loc) · 1.69 KB
/
main.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv
from keep_alive import keep_alive
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
OWNER_ID = os.getenv("OWNER_ID")
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(
command_prefix=commands.when_mentioned_or("!"),
description="OSAC Music Bot (Beta): Search and Plays music from ytube or a provided custom url",
intents=intents
)
# async def load_extensions():
@bot.event
async def on_ready():
print("Logged in as {0} ({0.id})".format(bot.user))
# loads all the cogs inside the cogs folder on startup
for filename in os.listdir("./cogs"):
if filename.endswith(".py") and filename != "__init__.py":
await bot.load_extension(f"cogs.{filename[:-3]}")
print("------")
@bot.command()
async def load(ctx, cname):
author = str(ctx.message.author.id)
if author == OWNER_ID:
bot.load_extension(f"cogs.{cname}")
await ctx.send(f"Successfully loaded {cname}")
else:
await ctx.send("Only the bot owner can use this command.")
@bot.command()
async def unload(ctx, cname):
author = str(ctx.message.author.id)
if author == OWNER_ID:
bot.unload_extension(f"cogs.{cname}")
else:
await ctx.send("Only the bot owner can use this command!")
@bot.command()
async def reload(ctx, cname):
author = str(ctx.message.author.id)
if author == OWNER_ID:
bot.unload_extension(f"cogs.{cname}")
bot.load_extension(f"cogs.{cname}")
await ctx.send(f"Successfully reloaded {cname}.")
else:
await ctx.send("Only the bot owner can use this command!")
bot.run(TOKEN)