Moved help to models, added extend list
This commit is contained in:
parent
bcfdb8c9aa
commit
7e09232e56
Binary file not shown.
|
@ -14,7 +14,7 @@ import sys
|
||||||
import cpuinfo
|
import cpuinfo
|
||||||
import math
|
import math
|
||||||
import psutil
|
import psutil
|
||||||
from extensions.helpcmd import TaciHelpCommand
|
from extensions.models.help import TaciHelpCommand
|
||||||
|
|
||||||
|
|
||||||
class Core(commands.Cog):
|
class Core(commands.Cog):
|
||||||
|
@ -120,8 +120,8 @@ Number of extensions present: {len(ctx.bot.cogs)}
|
||||||
|
|
||||||
# Provides status of extension
|
# Provides status of extension
|
||||||
if name is not None:
|
if name is not None:
|
||||||
status = "is" if f'extensions.{name}' in self.extensions_list else "is not"
|
status = "is" if name in self.extensions_list else "is not"
|
||||||
msg = f"**extensions.{name}** {status} currently loaded and/or existent."
|
msg = f"**{name}** {status} currently loaded and/or existent."
|
||||||
|
|
||||||
# Handles empty calls
|
# Handles empty calls
|
||||||
else:
|
else:
|
||||||
|
@ -184,6 +184,18 @@ Number of extensions present: {len(ctx.bot.cogs)}
|
||||||
else:
|
else:
|
||||||
await m.edit(content='Extension isn\'t loaded.')
|
await m.edit(content='Extension isn\'t loaded.')
|
||||||
|
|
||||||
|
@extend.command(name='list')
|
||||||
|
async def list_cmd(self, ctx):
|
||||||
|
"""Lists all extensions loaded by the bot."""
|
||||||
|
|
||||||
|
# Message Construction
|
||||||
|
msg = "**Loaded Extensions**\n\n"
|
||||||
|
msg += '\n'.join(f'`{e}`' for e in self.extensions_list)
|
||||||
|
msg += "\n\n_See the other subcommands of this command to manage them._"
|
||||||
|
|
||||||
|
# Message Sending
|
||||||
|
await ctx.send(msg)
|
||||||
|
|
||||||
@commands.command(aliases=['exit', 'reboot'])
|
@commands.command(aliases=['exit', 'reboot'])
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def restart(self, ctx):
|
async def restart(self, ctx):
|
||||||
|
|
|
@ -241,4 +241,8 @@ class TaciHelpCommand(commands.MinimalHelpCommand):
|
||||||
|
|
||||||
# Sends the completed help output.
|
# Sends the completed help output.
|
||||||
self.paginator.close_page() # TODO What does this do?
|
self.paginator.close_page() # TODO What does this do?
|
||||||
await self.send_pages()
|
await self.send_pages()
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
"""Lets helpcmd be added and reloaded as an extension."""
|
||||||
|
pass
|
22
main.py
22
main.py
|
@ -49,6 +49,7 @@ class Bot(commands.Bot):
|
||||||
def _init_extensions(self):
|
def _init_extensions(self):
|
||||||
"""Initializes extensions."""
|
"""Initializes extensions."""
|
||||||
|
|
||||||
|
# Extensions
|
||||||
for ext in os.listdir('extensions'):
|
for ext in os.listdir('extensions'):
|
||||||
if ext.endswith('.py'):
|
if ext.endswith('.py'):
|
||||||
try:
|
try:
|
||||||
|
@ -57,6 +58,27 @@ class Bot(commands.Bot):
|
||||||
f'extensions.{ext[:-3]}')
|
f'extensions.{ext[:-3]}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
# Models
|
||||||
|
for ext in os.listdir('extensions/models'):
|
||||||
|
if ext.endswith('.py'):
|
||||||
|
try:
|
||||||
|
bot.load_extension(f'extensions.models.{ext[:-3]}')
|
||||||
|
self.extensions_list.append(
|
||||||
|
f'extensions.models.{ext[:-3]}')
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
# Utils
|
||||||
|
for ext in os.listdir('extensions/utils'):
|
||||||
|
if ext.endswith('.py'):
|
||||||
|
try:
|
||||||
|
bot.load_extension(f'extensions.utils.{ext[:-3]}')
|
||||||
|
self.extensions_list.append(
|
||||||
|
f'extensions.utils.{ext[:-3]}')
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
|
||||||
async def _get_prefix_new(self, bot, msg):
|
async def _get_prefix_new(self, bot, msg):
|
||||||
"""More flexible check for prefix."""
|
"""More flexible check for prefix."""
|
||||||
|
|
Loading…
Reference in New Issue