Skip to content

Commit

Permalink
add default checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rtk-rnjn committed Jul 28, 2023
1 parent 42a38d3 commit da37ef2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cogs/automod/parsers/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def __repr__(self) -> str:
return f"<Condition data={self.data}>"

async def check(self, **kw) -> bool:
if not self.data:
return True

for condition in self.data:
func = getattr(self, condition["name"])
if not await maybe_coroutine(func, **kw):
Expand Down
2 changes: 2 additions & 0 deletions cogs/automod/parsers/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def __repr__(self) -> str:
return f"<Trigger data={self.data}>"

async def check(self, **kw) -> bool:
if not self.data:
return False
return self.operator(getattr(self, tgr["type"])(**{**kw, **tgr}) for tgr in self.data)

def build_cooldowns(self) -> None:
Expand Down
3 changes: 2 additions & 1 deletion cogs/automod/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@


def parse_dict(data: dict[str, Any]) -> str:
return "".join(f"`{k}: {v}`\n" if i == 0 else f"` {k}: {v}`\n" for i, (k, v) in enumerate(data.items()))
data = {k: v for k, v in data.items() if v}
return f"`{data}`"


class Automod(ParrotView):
Expand Down

0 comments on commit da37ef2

Please sign in to comment.