-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.py
More file actions
59 lines (40 loc) · 1.51 KB
/
commands.py
File metadata and controls
59 lines (40 loc) · 1.51 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
51
52
53
54
55
56
57
58
59
"""
Overall commands cog.
Loads in other cogs and manages cog reloading.
"""
import os
from discord.ext import commands
class SecHitComms(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print("Sechit Running")
@commands.command()
@commands.is_owner()
async def reload(self, ctx, cogName=None):
print("Reloading Cogs")
game = self.bot.get_cog('GameCommands')
games = game.games
if cogName:
if f'cog_{cogName}.py' in os.listdir('./cogs'):
print(f'Reloading cog {cogName}')
self.bot.reload_extension(f'cogs.cog_{cogName}')
else:
await ctx.send(f'Did not find cog {cogName}.')
return
else:
for cog in os.listdir('./cogs'):
if cog.startswith('cog_'):
print(f'Reloading cog {os.path.splitext(cog)[0]}')
self.bot.reload_extension(f'cogs.{os.path.splitext(cog)[0]}')
if not(cogName) or cogName == 'games':
game = self.bot.get_cog('GameCommands')
game._load(games)
await ctx.send("Reloaded successfully.\n")
def setup(bot):
bot.add_cog(SecHitComms(bot))
for cog in os.listdir('./cogs'):
if cog.startswith('cog_'): #Cog prefix
print(f"Loading cog {os.path.splitext(cog)[0]}")
bot.load_extension(f'cogs.{os.path.splitext(cog)[0]}') #Stripping .py from cog name