From a39f297669677723ddcac809e17d26a0410bcf9d Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Mon, 2 May 2022 01:57:35 -0600 Subject: [PATCH] Remove molter --- jarvis/client.py | 8 ++++---- jarvis/cogs/botutil.py | 25 ++++++++++++------------- pyproject.toml | 1 - 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/jarvis/client.py b/jarvis/client.py index b9dd128..1eb5223 100644 --- a/jarvis/client.py +++ b/jarvis/client.py @@ -19,7 +19,7 @@ from dis_snek.models.discord.channel import DMChannel from dis_snek.models.discord.embed import EmbedField from dis_snek.models.discord.enums import Permissions from dis_snek.models.discord.message import Message -from dis_snek.models.snek.context import Context, InteractionContext, MessageContext +from dis_snek.models.snek.context import Context, InteractionContext, PrefixedContext from dis_snek.models.snek.tasks.task import Task from dis_snek.models.snek.tasks.triggers import IntervalTrigger from jarvis_core.db import q @@ -93,7 +93,7 @@ class Jarvis(Snake): if isinstance(ctx, InteractionContext) and ctx.target_id: kwargs["context target"] = ctx.target args = " ".join(f"{k}:{v}" for k, v in kwargs.items()) - elif isinstance(ctx, MessageContext): + elif isinstance(ctx, PrefixedContext): args = " ".join(args) self.logger.debug(f"Running command `{name}` with args: {args or 'None'}") @@ -152,7 +152,7 @@ class Jarvis(Snake): if isinstance(v, str) and len(v) > 100: v = v[97] + "..." arg_str += f"{v}\n" - elif isinstance(ctx, MessageContext): + elif isinstance(ctx, PrefixedContext): for v in ctx.args: if isinstance(v, str) and len(v) > 100: v = v[97] + "..." @@ -214,7 +214,7 @@ class Jarvis(Snake): if len(v) > 100: v = v[:97] + "..." args.append(f"{KEY_FMT}{k}:{VAL_FMT}{v}{RESET}") - elif isinstance(ctx, MessageContext): + elif isinstance(ctx, PrefixedContext): for v in ctx.args: if isinstance(v, str) and len(v) > 100: v = v[97] + "..." diff --git a/jarvis/cogs/botutil.py b/jarvis/cogs/botutil.py index d72d9fd..2dd8649 100644 --- a/jarvis/cogs/botutil.py +++ b/jarvis/cogs/botutil.py @@ -5,11 +5,10 @@ from io import BytesIO import psutil from aiofile import AIOFile, LineReader -from dis_snek import Scale, Snake +from dis_snek import PrefixedContext, Scale, Snake, prefixed_command from dis_snek.client.errors import HTTPException from dis_snek.models.discord.embed import EmbedField from dis_snek.models.discord.file import File -from molter import MessageContext, msg_command from rich.console import Console from jarvis.utils import build_embed @@ -24,12 +23,12 @@ class BotutilCog(Scale): self.logger = logging.getLogger(__name__) self.add_scale_check(self.is_owner) - async def is_owner(self, ctx: MessageContext) -> bool: + async def is_owner(self, ctx: PrefixedContext) -> bool: """Checks if author is bot owner.""" return ctx.author.id == self.bot.owner.id - @msg_command(name="tail") - async def _tail(self, ctx: MessageContext, count: int = 10) -> None: + @prefixed_command(name="tail") + async def _tail(self, ctx: PrefixedContext, count: int = 10) -> None: lines = [] async with AIOFile("jarvis.log", "r") as af: async for line in LineReader(af): @@ -46,8 +45,8 @@ class BotutilCog(Scale): else: await ctx.reply(content=f"```\n{log}\n```") - @msg_command(name="log") - async def _log(self, ctx: MessageContext) -> None: + @prefixed_command(name="log") + async def _log(self, ctx: PrefixedContext) -> None: async with AIOFile("jarvis.log", "r") as af: with BytesIO() as file_bytes: raw = await af.read_bytes() @@ -56,12 +55,12 @@ class BotutilCog(Scale): log = File(file_bytes, file_name="jarvis.log") await ctx.reply(content="Here's the latest log", file=log) - @msg_command(name="crash") - async def _crash(self, ctx: MessageContext) -> None: + @prefixed_command(name="crash") + async def _crash(self, ctx: PrefixedContext) -> None: raise Exception("As you wish") - @msg_command(name="sysinfo") - async def _sysinfo(self, ctx: MessageContext) -> None: + @prefixed_command(name="sysinfo") + async def _sysinfo(self, ctx: PrefixedContext) -> None: st_ts = int(self.bot.start_time.timestamp()) ut_ts = int(psutil.boot_time()) fields = ( @@ -75,8 +74,8 @@ class BotutilCog(Scale): embed.set_image(url=self.bot.user.avatar.url) await ctx.send(embed=embed) - @msg_command(name="update") - async def _update(self, ctx: MessageContext) -> None: + @prefixed_command(name="update") + async def _update(self, ctx: PrefixedContext) -> None: status = await update(self.bot) if status: console = Console() diff --git a/pyproject.toml b/pyproject.toml index e0bca01..7e0bdaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,6 @@ aiohttp = "^3.8.1" pastypy = "^1.0.1" dateparser = "^1.1.1" aiofile = "^3.7.4" -molter = "^0.11.0" asyncpraw = "^7.5.0" rook = "^0.1.170" rich = "^12.3.0"