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 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-modding-framework

v1.0.10

Published

An attempt at a flexible framework for modifying the discord client

Downloads

3

Readme

Introduction

This repository serves as two things:

  • A mod manager for discord, allowing for easy installation of modifications to the app
  • A package for providing an easy way to make mods in a format supported by the mod manager

Mod Manager

The mod manager allows running modifications to the discord app. It does this by patching the discord app using asar. Mods are JSON files that contain callbacks for various events, such as when the DOM is ready, when the app is ready, etc. They also contain mod metadata.

Usage

Mod Manager

If you aren't a developer, find the latest release here. I also recommend reading the "Using the mod manager" section below.

Otherwise, see the development section below under the "Using the mod manager" section.

Using the mod manager

Here is an image of the mod manager in action:

Mod Manager

Currently implemented features as shown are:

  • Refresh: Refreshes the list of installed mods. Should only be necessary if you manually move a mod into the mod folders.
  • Patch: Patches the current modlist into the discord app.
  • Restore: Restores the discord app to its original state.
  • Install: Allows you to select a folder containing a mod.json file. This will install the mod.
  • The url field and install button: Allows you to install a mod from a git repository. The url should be the url to the repository, not the mod.json file.

Mod list

The mod list shows all installed mods. It shows the mod id, description, version, author and repository. Most of these are optional, so don't be surprised if they are missing. Each mod also contains an enabled/disabled toggle, which allows you to disable a mod without uninstalling it. This requires a patch to take effect. The mod list also contains a button to uninstall a mod, which removes all files related to the mod. This also requires a patch to take effect. At the top left of every mod you can see a little arrow. Clicking this expands/collapses the detailed view that includes configurations, dependencies and the full mod description.

Configuration

Mod developers now have the option of including configurations. These come with default values, so you probably won't have to touch them unless you feel adventurous or the mod description / repository gives you instructions to do so.

Modding Framework

npm i -D discord-modding-framework
import { Mod } from 'discord-modding-framework';
import fs from 'fs';
import path from 'path';

// mod constructor takes the following arguments:
// obj: {id: string, dependencies?: Dependency[], version?: string, repository?: string, author?: string, description?: string, homepage?: string, fullDescription?: string, config?: ConfigurationField[]}
// where dependencies are objects with an id, version and optional repository and
// configuration fields are objects with a name, description, type and optional default value.
// the type can be one of 'boolean', 'string', 'number'.

const modOpts = {
  id: 'example-mod',
  version: '1.0.0',
  config: [
    {
      name: 'enabled',
      description: 'Whether the mod is enabled',
      type: 'boolean',
      defaultValue: true
    },
    {
      name: 'message',
      description: 'The message to log to the console',
      type: 'string',
      defaultValue: 'Hello world!'
    }
  ]
}
const exampleMod = new Mod(modOpts);
exampleMod.on('dom-ready', (mainWindow) => {
  // do stuff with the main window
});
exampleMod.once('dom-ready', (mainWindow, configuration) => {
  // do stuff with the main window or configuration
  // the configuration is a map of your configuration names to their (value ?? default value)s
  // configuration is also available inside the window through window.modConfig[configName] so you can do something like:
  if(configuration.get('enabled')) {
    mainWindow.webContents.executeJavaScript(`
      console.log(window.modConfig['message'])
    `);
  }
  // Beware! This is not fully tested, but it is in the works.
});
// There is more stuff yet, hang in there:
exampleMod.on('ready', Mod.getCallbackFromFile(path.join(__dirname, 'ready.js'))); // this will run the code in ready.js in the window when the app is ready
const modFile = path.join(__dirname 'mod.json');
// this will create a mod.json file in the root of your project. Perfect for the install from repository feature of the mod manager.
fs.writeFileSync(modFile, JSON.stringify(exampleMod.getJSON(), null, 2));

Let's check out "ready.js" as well:

const msg = window.modConfig['message'];
// make sure not to try ddoing something like this:
// if (!msg) return;
// because the code is run in the window where it cannot return.
// instead, do something like this:
function run() {
  if (!msg) return;
  console.log(msg);
}
run();

// or this:
if (msg) {
  console.log(msg);
}

As you can see, it's not very complicated.

This new mod can then be installed by the mod manager. If you keep your mod in a git repository, you can install it directly from there as long as mod.json is in the root of the repository, otherwise you can navigate to the folder containing mod.json and install it from there using the file picker dialog.

Here is a real mod as an example that uses configs: frodi-karlsson-modpack

Development

The mod manager is built using electron. I've tried to keep the app small, so there's no react or anything like that. The UI is built using vanilla HTML, CSS and JS.

Clone the repository and run npm i to install dependencies.

Use npm run build to build the electron app. Use npm run serve to build and run the electron app.