Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

Commit

Permalink
Push all the files.
Browse files Browse the repository at this point in the history
  • Loading branch information
unclamped committed Dec 16, 2022
1 parent dcc88dc commit 2a0af0b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 92 deletions.
85 changes: 21 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,33 @@
# Replugged plugin template
# Show Token

[Use this template](https://github.com/replugged-org/plugin-template/generate)

## Prerequisites

- NodeJS
- pnpm: `npm i -g pnpm`
- [Replugged](https://github.com/replugged-org/replugged#installation)
Print your user token to the DevTools console.

## Install

1. [Create a copy of this template](https://github.com/replugged-org/plugin-template/generate)
2. Clone your new repository and cd into it
3. Install dependencies: `pnpm i`
4. Build the plugin: `pnpm run build`
5. Reload Discord to load the plugin

The unmodified plugin will log "Typing prevented" in the console when you start typing in any
channel.

## Development

The code must be rebuilt after every change. You can use `pnpm run watch` to automatically rebuild
the plugin when you save a file.

Building using the script above will automatically install the updated version of the plugin in
Replugged. You can find the plugin folder directories for your OS
[here](https://github.com/replugged-org/replugged#installing-plugins-and-themes).
If you don't want to install the updated version, set the `NO_INSTALL` environment variable with any
value: `NO_INSTALL=true pnpm run build`.

You can format the code by running `pnpm run lint:fix`. The repository includes VSCode settings to
automatically format on save.
Either download the precompiled plugin, or compile it by yourself.

API docs coming soon(tm)
### Precompiled

## Distribution
1. [Go to the releases tab of this repo](https://github.com/unclamped/show-token-plugin/releases)
and download the .asar file for the latest release of this plugin
2. Copy the downloaded file to your Replugged plugins folder

For plugin distribution, Replugged uses bundled `.asar` files. Bundled plugins can be installed to
the same plugin folder as listed above.
- Windows: `%APPDATA%/replugged/plugins`
- macOS: `~/Library/Application Support/replugged/plugins`
- Other: `$XDG_CONFIG_HOME/replugged/plugins` or `~/.config/replugged/plugins`

This repository includes a GitHub workflow to compile and publish a release with the asar file. To
trigger it, create a tag with the version number preceded by a `v` (e.g. `v1.0.0`) and push it to
GitHub:
3. Reload Discord to load the plugin

```sh
git tag v1.0.0
git push --tags
```
### Built from source

The Replugged updater (coming soon™) will automatically check for updates on the repository
specified in the manifest. Make sure to update it to point to the correct repository!
For this you'll need a couple of things first:

You can manually compile the asar file with `pnpm run build-and-bundle`.

## Troubleshooting

### Make sure Replugged is installed and running.

Open Discord settings and make sure the Replugged tab is there. If not,
[follow these instructions](https://github.com/replugged-org/replugged#installation) to install
Replugged.

### Make sure the plugin is installed.

Check the [plugin folder](https://github.com/replugged-org/replugged#installing-plugins-and-themes)
for your OS and make sure the plugin is there. If not, make sure you have built the plugin and that
the `NO_INSTALL` environment variable is not set.
You can run `replugged.plugins.list().then(console.log)` in the console to see a list of plugins in
the plugin folder.

### Make sure the plugin is running.
- Git
- NodeJS
- pnpm: (can be installed with `npm i -g pnpm`)
- [Replugged](https://github.com/replugged-org/replugged#installation)

Check the console for a message saying `[Replugged:Plugin:Plugin Template] Plugin started`. If you
don't see it, try reloading Discord. If that doesn't work, check for any errors in the console.
1. Clone this repository and cd into it
2. Install dependencies: `pnpm i`
3. Build the plugin: `pnpm run build`
4. Reload Discord to load the plugin
16 changes: 8 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"id": "dev.replugged.PluginTemplate",
"name": "Plugin Template",
"description": "A plugin template",
"id": "dev.unclamped.show-token",
"name": "Show Token",
"description": "Print your user token to the DevTools console.",
"author": {
"name": "replugged",
"discordID": "1000992611840049192",
"github": "replugged-org"
"name": "Maru",
"discordID": "969039246629437521",
"github": "unclamped"
},
"version": "1.0.1",
"version": "1.0.0",
"updater": {
"type": "github",
"id": "replugged-org/plugin-template"
"id": "unclamped/show-token-plugin"
},
"license": "MIT",
"type": "replugged-plugin",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "plugin-template",
"name": "show-token",
"version": "1.0.0",
"description": "A plugin template",
"description": "Print your user token to the DevTools console.",
"engines": {
"node": ">=14.0.0"
},
Expand Down
27 changes: 9 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
import { Injector, webpack } from "replugged";
import { webpack } from "replugged";
import { AnyFunction } from "replugged/dist/types/util";

const inject = new Injector();

export async function start(): Promise<void> {
const typingMod = (await webpack.waitForModule(webpack.filters.byProps("startTyping"))) as {
startTyping: AnyFunction;
};
const getChannelMod = (await webpack.waitForModule(webpack.filters.byProps("getChannel"))) as {
getChannel: (id: string) => {
name: string;
};
const getTokenMod = (await webpack.waitForModule(webpack.filters.byProps("getToken"))) as {
getToken: AnyFunction;
};

if (typingMod && getChannelMod) {
inject.instead(typingMod, "startTyping", ([channel]) => {
const channelObj = getChannelMod.getChannel(channel as string);
console.log(`Typing prevented! Channel: #${channelObj?.name ?? "unknown"} (${channel}).`);
});
if (getTokenMod) {
const token = getTokenMod.getToken();
console.log(token);
}
console.log(getTokenMod);
}

export function stop(): void {
inject.uninjectAll();
}
// It took me way too long to figure this out, I did not remember anything about types at all prior to this.
// Thanks a lot albert n fish for helping me, I had really dumbass questions but you are were really patient <3

0 comments on commit 2a0af0b

Please sign in to comment.