mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2025-08-05 06:01:06 +00:00
Add cog load actions, solve the bug we found on verification reload
This commit is contained in:
parent
319385f100
commit
fca8684f34
|
@ -4,6 +4,7 @@ from discord.ext.commands import Cog
|
||||||
import traceback
|
import traceback
|
||||||
import inspect
|
import inspect
|
||||||
import re
|
import re
|
||||||
|
import config
|
||||||
from helpers.checks import check_if_bot_manager
|
from helpers.checks import check_if_bot_manager
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,20 +22,6 @@ class Admin(Cog):
|
||||||
await ctx.send(":wave: Goodbye!")
|
await ctx.send(":wave: Goodbye!")
|
||||||
await self.bot.logout()
|
await self.bot.logout()
|
||||||
|
|
||||||
@commands.guild_only()
|
|
||||||
@commands.check(check_if_bot_manager)
|
|
||||||
@commands.command()
|
|
||||||
async def load(self, ctx, ext: str):
|
|
||||||
"""Loads a cog, bot manager only."""
|
|
||||||
try:
|
|
||||||
self.bot.load_extension("cogs." + ext)
|
|
||||||
except:
|
|
||||||
await ctx.send(f':x: Cog loading failed, traceback: '
|
|
||||||
f'```\n{traceback.format_exc()}\n```')
|
|
||||||
return
|
|
||||||
self.bot.log.info(f'Loaded ext {ext}')
|
|
||||||
await ctx.send(f':white_check_mark: `{ext}` successfully loaded.')
|
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.check(check_if_bot_manager)
|
@commands.check(check_if_bot_manager)
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -105,6 +92,11 @@ class Admin(Cog):
|
||||||
for msg in sliced_message:
|
for msg in sliced_message:
|
||||||
await ctx.send(msg)
|
await ctx.send(msg)
|
||||||
|
|
||||||
|
async def cog_load_actions(self, cog_name):
|
||||||
|
if cog_name == "verification":
|
||||||
|
verif_channel = self.bot.get_channel(config.welcome_channel)
|
||||||
|
await self.bot.do_resetalgo(verif_channel, "cog load")
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.check(check_if_bot_manager)
|
@commands.check(check_if_bot_manager)
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -117,16 +109,31 @@ class Admin(Cog):
|
||||||
cogs_to_reload = re.findall(r'cogs/([a-z_]*).py[ ]*\|', git_output)
|
cogs_to_reload = re.findall(r'cogs/([a-z_]*).py[ ]*\|', git_output)
|
||||||
for cog in cogs_to_reload:
|
for cog in cogs_to_reload:
|
||||||
try:
|
try:
|
||||||
self.bot.unload_extension("cogs." + cog)
|
self.bot.reload_extension("cogs." + cog)
|
||||||
self.bot.load_extension("cogs." + cog)
|
|
||||||
self.bot.log.info(f'Reloaded ext {cog}')
|
self.bot.log.info(f'Reloaded ext {cog}')
|
||||||
await ctx.send(f':white_check_mark: `{cog}` '
|
await ctx.send(f':white_check_mark: `{cog}` '
|
||||||
'successfully reloaded.')
|
'successfully reloaded.')
|
||||||
|
await self.cog_load_actions(cog)
|
||||||
except:
|
except:
|
||||||
await ctx.send(f':x: Cog reloading failed, traceback: '
|
await ctx.send(f':x: Cog reloading failed, traceback: '
|
||||||
f'```\n{traceback.format_exc()}\n```')
|
f'```\n{traceback.format_exc()}\n```')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.check(check_if_bot_manager)
|
||||||
|
@commands.command()
|
||||||
|
async def load(self, ctx, ext: str):
|
||||||
|
"""Loads a cog, bot manager only."""
|
||||||
|
try:
|
||||||
|
self.bot.load_extension("cogs." + ext)
|
||||||
|
await self.cog_load_actions(ext)
|
||||||
|
except:
|
||||||
|
await ctx.send(f':x: Cog loading failed, traceback: '
|
||||||
|
f'```\n{traceback.format_exc()}\n```')
|
||||||
|
return
|
||||||
|
self.bot.log.info(f'Loaded ext {ext}')
|
||||||
|
await ctx.send(f':white_check_mark: `{ext}` successfully loaded.')
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.check(check_if_bot_manager)
|
@commands.check(check_if_bot_manager)
|
||||||
@commands.command()
|
@commands.command()
|
||||||
|
@ -146,8 +153,8 @@ class Admin(Cog):
|
||||||
self.lastreload = ext
|
self.lastreload = ext
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.bot.unload_extension("cogs." + ext)
|
self.bot.reload_extension("cogs." + ext)
|
||||||
self.bot.load_extension("cogs." + ext)
|
await self.cog_load_actions(ext)
|
||||||
except:
|
except:
|
||||||
await ctx.send(f':x: Cog reloading failed, traceback: '
|
await ctx.send(f':x: Cog reloading failed, traceback: '
|
||||||
f'```\n{traceback.format_exc()}\n```')
|
f'```\n{traceback.format_exc()}\n```')
|
||||||
|
|
Loading…
Reference in a new issue