Added config checking, event listeners, etc.

Can track added features by comparing TODO list.
This commit is contained in:
2021-07-16 23:53:31 +01:00
parent 1d355e3b2d
commit 51a01bab49
22 changed files with 346 additions and 77 deletions

View File

@ -10,10 +10,14 @@ from discord_slash.utils.manage_commands import create_choice, create_option # S
from bot import clearConfig, configFile, loadCog, loadCogs, setConfig, unloadCog, unloadCogs, yaml_dump, yaml_load
##### Debug Cog
class Debug(commands.Cog):
class Debug(commands.Cog, name='Debug Commands'):
def __init__(self, client):
self.client = client
#### Permission Check: Only available to the bot's maintainer.
async def cog_check(self, ctx):
return ctx.author.id == int(os.getenv('BOT_MAINTAINER_ID'))
@commands.command(
name='reloadcogs',
description='Reloads cogs within the specified category, or provide `all` for all cogs. Default: `all`.',
@ -22,7 +26,7 @@ class Debug(commands.Cog):
async def _reload(self, ctx, cog_category: str='all'):
unloadCogs(cog_category)
loadCogs(cog_category)
await ctx.repky(f'`{cog_category}` cogs have been reloaded.')
await ctx.reply(f'`{cog_category}` cogs have been reloaded.')
@commands.command(
name='unloadcogs',
@ -32,7 +36,7 @@ class Debug(commands.Cog):
async def _unloadcogs(self, ctx, cog_category: str='all'):
unloadCogs(cog_category)
loadCogs(cog_category)
await ctx.repky(f'`{cog_category}` cogs have been unloaded.')
await ctx.reply(f'`{cog_category}` cogs have been unloaded.')
@commands.command(
name='loadcogs',
@ -42,7 +46,7 @@ class Debug(commands.Cog):
async def _loadcogs(self, ctx, cog_category: str='all'):
unloadCogs(cog_category)
loadCogs(cog_category)
await ctx.repky(f'`{cog_category}` cogs have been loaded.')
await ctx.reply(f'`{cog_category}` cogs have been loaded.')
@commands.command(
name='deletecommands',
@ -65,10 +69,12 @@ class Debug(commands.Cog):
@commands.command(
name='retrievecommands',
aliases=['slashcommands','retrieveslashcommands']
aliases=['slashcommands','retrieveslashcommands'],
description='Debugging command that retrieves all slash commands currently registered for this guild and this bot to the Python console.',
brief='Retrieves registered slash commands to console.'
)
async def _retrievecommands(self, ctx:commands.Context):
c = await utils.manage_commands.get_all_commands(client.user.id,os.getenv('TEST_3_TOKEN'),guild_id=ctx.guild.id)
c = await utils.manage_commands.get_all_commands(self.client.user.id,os.getenv('TEST_3_TOKEN'),guild_id=ctx.guild.id)
print(c)
@commands.command(
@ -81,7 +87,7 @@ class Debug(commands.Cog):
conf = yaml_load(configFile)
for key in list(conf):
clearConfig(key)
ctx.reply(f'Config entries have been cleared.')
await ctx.reply(f'Config entries have been cleared.')
@commands.command(
name='setconfig',
@ -91,7 +97,7 @@ class Debug(commands.Cog):
)
async def _setconfig(self, ctx:commands.Context):
setConfig(ctx.guild)
ctx.reply(f'Config entry has been added for guild `{ctx.guild.name}`.')
await ctx.reply(f'Config entry has been added for guild `{ctx.guild.name}`.')
def setup(client):
client.add_cog(Debug(client))