Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Git failed to push ;-;
Browse files Browse the repository at this point in the history
  • Loading branch information
showierdata9978 committed Nov 29, 2023
1 parent 0ecdea9 commit 356df8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion MeowerBot/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Cog:
commands: dict[str, AppCommand]
callbacks: dict[str, list[types.CoroutineType[Any, Any, Any]]]
callbacks: dict[str, list[types.CoroutineType]]

__instence__: Union["Cog", None] = None

Expand All @@ -19,6 +19,12 @@ def __init__(self) -> None:
self.update_commands()

def update_commands(self):
if not hasattr(self, "commands"):
self.commands = {}

if not hasattr(self, "callbacks"):
self.callbacks = {}

for command in self.__dir__():
attr = getattr(self, command)
if isinstance(attr, AppCommand):
Expand Down
15 changes: 15 additions & 0 deletions tests/intergration/integration_login.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from MeowerBot import Bot
from MeowerBot.context import Context
from MeowerBot.cog import Cog
from MeowerBot.command import command

import logging

Expand All @@ -25,9 +27,22 @@ async def login(t):
async def ping(ctx: Context):
await ctx.send_msg("Pong!\n My latency is: " + str(bot.latency))

class Ping(Cog):
def __init__(self, bot):
self.bot = bot

@command()
async def cog_ping(self, ctx: Context):
await ctx.send_msg("Pong!\n My latency is: " + str(self.bot.latency))

@cog_ping.subcommand()
async def ping(self, ctx: Context):
await ctx.send_msg("Pong!\n My latency is: " + str(self.bot.latency))

@ping.subcommand(name="pong")
async def pong(ctx: Context, *message: str):
await ctx.send_msg(f"Pong!{" ".join(message)}")

bot.register_cog(Ping(bot))
bot.register_cog(HelpExt(bot, disable_command_newlines=True))
bot.run(env["uname"], env["pswd"])

0 comments on commit 356df8e

Please sign in to comment.