Added enable and disable to cogs

This commit is contained in:
2022-09-07 22:17:13 +03:00
parent f573d36d42
commit 9d4a6ffc04
2 changed files with 25 additions and 9 deletions

19
bot.py
View File

@@ -28,7 +28,7 @@ bot = commands.Bot(command_prefix=determine_prefix,
)
asyncio.run(work_with_cogs('load', bot, cog_list()))
asyncio.run(work_with_cogs('load', bot, asyncio.run(cog_list())))
@bot.event
@@ -50,7 +50,9 @@ async def on_ready():
choices=[
OptionChoice("load", "load"),
OptionChoice("unload", "unload"),
OptionChoice("reload", "reload")
OptionChoice("reload", "reload"),
OptionChoice("enable", "enable"),
OptionChoice("disable", "disable"),
]
),
Option(
@@ -61,15 +63,18 @@ async def on_ready():
]
)
@commands.is_owner()
async def slash_cogs(inter, what_do, cog: str = cog_list()) -> None:
print(type(inter.guild.text_channels))
async def slash_cogs(inter, what_do, cog: str = asyncio.run(cog_list())) -> None:
await work_with_cogs(what_do, bot, cog)
await inter.response.send_message(f'Cogs are {what_do}ed', ephemeral=True)
await inter.response.send_message(f'Cog {cog} is {what_do}ed', ephemeral=True)
@slash_cogs.autocomplete('cog')
async def _cog_opt(inter: disnake.ApplicationCommandInteraction, current: str) -> List[OptionChoice]:
_list = cog_list()
async def _cog_opt(inter: disnake.ApplicationCommandInteraction, current: str, what_do) -> List[OptionChoice]:
_what = ['load', 'reload', 'unload', 'disable']
if what_do in _what:
_list = await cog_list()
elif what_do == 'enable':
_list = await cog_list('./cogs/disabled/')
return [
OptionChoice(name=choice, value=choice)
for choice in _list if current.lower() in choice.lower()