npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

koishi-plugin-eval-unsafe

v0.2.0

Published

Command to debug Koishi with JavaScript

Readme

koishi-plugin-eval-unsafe

npm

执行 JavaScript 以调试 Koishi

用法介绍

eval-unsafe <JavaScript代码>

该指令执行代码时没有任何沙箱措施,仅适用于管理员调试,默认需要 4 级权限。

代码执行的作用域中存在以下局部变量:

  • require
  • ctx
  • cmd = ctx.command("eval-unsafe")
  • argv
  • session
  • event = session.event
  • user = session.user
  • channel = session.channel
  • guild = session.guild
  • userId = session.userId
  • channelId = session.channelId
  • guildId = session.guildId
  • selfId = session.selfId
  • app = session.app
  • bot = session.bot
  • send = async x => void await session.send(x)
  • exec = x => session.execute(x, true)
  • inspect ≈ require("util").inspect(但对于Error对象会自动精简调用堆栈输出)

最后执行的一个语句若为表达式,则会输出其结果,若为Promise则会等待其完成后输出,但undefined不会输出。值为字符串会直接输出文本,值为 Koishi 的ElementElement组成的数组(也可包含字符串但不能全为字符串)时会作为消息元素输出,否则会使用inspect函数格式化后输出。若代码抛出异常或得到的Promise被 reject,也会将异常(reject 原因)值inspect后输出。

也可使用ctx.logger.info()输出内容到日志。

0.2.0 版本新增:代码若使用顶层await,插件会改用new (async () => {}).constructor(...)()方法执行,并自动在最后一个语句为表达式时将其改写为return语句。

已知问题:若await后为圆括号,则可能会被解析成调用名为await的函数,导致不触发该机制。可以通过写两个await来绕过此问题(如await await (_ => doSomething())())。