sync commands on startup
This commit is contained in:
parent
f963e701ab
commit
4737a47ebe
2 changed files with 2 additions and 23 deletions
|
@ -20,6 +20,7 @@ class Wulkabot(commands.Bot):
|
|||
async def setup_hook(self) -> None:
|
||||
self.http_client = aiohttp.ClientSession()
|
||||
await self.load_extensions(cogs)
|
||||
await self.tree.sync()
|
||||
|
||||
async def on_connect(self) -> None:
|
||||
print(f"Connected as {self.user}")
|
||||
|
@ -42,7 +43,7 @@ class Wulkabot(commands.Bot):
|
|||
return name.rsplit(".", maxsplit=1)[-1]
|
||||
|
||||
extensions = set()
|
||||
for package in pkgutil.walk_packages(module.__path__, module.__name__ + "."):
|
||||
for package in pkgutil.walk_packages(module.__path__, f"{module.__name__}."):
|
||||
if package.ispkg or unqualify(package.name).startswith("_"):
|
||||
continue
|
||||
extensions.add(package.name)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
from discord.ext import commands
|
||||
|
||||
from .. import bot
|
||||
|
||||
|
||||
class Development(commands.Cog):
|
||||
def __init__(self, bot: bot.Wulkabot) -> None:
|
||||
super().__init__()
|
||||
self.bot = bot
|
||||
|
||||
@commands.command()
|
||||
@commands.has_role("Maintainer")
|
||||
async def sync(self, ctx: commands.Context):
|
||||
"""Synchronizuje komendy bota"""
|
||||
|
||||
commands = await self.bot.tree.sync()
|
||||
commands_str = ", ".join(c.name for c in commands)
|
||||
await ctx.reply(f"Zsynchronizowano **{len(commands)}** komend\n{commands_str}")
|
||||
|
||||
|
||||
async def setup(bot: bot.Wulkabot):
|
||||
await bot.add_cog(Development(bot))
|
Loading…
Reference in a new issue