Remove molter
This commit is contained in:
parent
d962f9e268
commit
a39f297669
3 changed files with 16 additions and 18 deletions
|
@ -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] + "..."
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue