-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbot.py
56 lines (44 loc) · 1.57 KB
/
bot.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
import os
from dotenv import load_dotenv
import discord
from discord.ext import commands
load_dotenv()
secret_key = os.getenv("BOT_KEY")
command_prefix = '!!'
bot = commands.Bot(command_prefix)
@bot.event
async def on_ready():
print(f'Bot is Online~\n{bot.user.name}, (ID: {bot.user.id})\n')
#Loads cogs
print('Loading cogs:')
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.load_extension(f'cogs.{filename[:-3]}')
print(f'- {(filename[:-3]).title()} commands loaded')
#Set status
await bot.change_presence(status = discord.Status.online, activity=discord.Game("Ready to Help!"))
@bot.event
async def on_disconnect():
print('Bot Disconnected...')
@bot.command()
async def load(ctx, extension):
bot.load_extension(f'cogs.{extension}')
await ctx.send(f'{extension.title()} cog has been loaded')
@bot.command()
async def unload(ctx, extension):
bot.unload_extension(f'cogs.{extension}')
await ctx.send(f'{extension.title()} cog was unloaded')
@bot.command()
async def reload(ctx):
try:
for filename in os.listdir('./cogs'):
if filename.endswith('.py'):
bot.unload_extension(f'cogs.{filename[:-3]}')
bot.load_extension(f'cogs.{filename[:-3]}')
print(f'- {(filename[:-3]).title()} commands reloaded')
await ctx.send(f'Cogs reloaded succesfully')
except Exception:
await ctx.send(f"Something's not right...")
print(Exception)
if __name__ == "__main__":
bot.run(secret_key)