Skip to content

Instantly share code, notes, and snippets.

@BobbyWibowo
Last active July 30, 2022 20:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BobbyWibowo/2a73ec8fa2197f156a8f8a81a2ae0aa0 to your computer and use it in GitHub Desktop.
Save BobbyWibowo/2a73ec8fa2197f156a8f8a81a2ae0aa0 to your computer and use it in GitHub Desktop.

HOWTO

Table of Contents

Downloads

BetterDiscord

Plugin (upstream): https://magane.moe/

Plugin (upstream, standalone BetterDiscord plugin): https://github.com/Pitu/Magane/blob/master/dist/magane.plugin.js

Install it the same way you install any other BetterDiscord plugins.

JSON-based custom packs

Since PR #58, custom packs can now be easily imported from the UI.

image

Check out https://magane.fiery.me/configs/ for some valid examples.

In the JSON files in the link above, you will find that they are mostly using template URLs.
However, that is now optional!
files and thumbs arrays now support full-length URLs, and they also support mixing files of any kind.

Here is a small example of mixing PNG and some GIFs: https://magane.fiery.me/configs/Life_on_Hyperion_3.json.


Console functions

Syntaxes for these may be outdated.

Please also refer to the source codes at the following lines:
https://github.com/Pitu/Magane/blob/16c8a67468b7a2fc03a79c77ce4caec7c27e9f29/src/App.svelte#L652-L802

Magane now have some functions that can be executed from the Console (Ctrl+Shift+I in Discord app):

magane.appendPack(title, firstid, count, animated)

Use this to add packs from the LINE web store (in case you don't want to bother Pitu/Kana 👀).

This was inspired by bd-linestickers plugin, and was originally done in harjitmoe's fork. I only expanded upon the functionality (e.g. animated stickers support), so props to those folks!

Unfortunately Discord recently stopped animating APNG (Animated PNG) in chat, which is the format LINE uses for their animated stickers.
And thus animated stickers added with this method will not be animated.
So if you really need those animated stickers, you will have to request Pitu/Kana to add them to Magane (since they will be converted to GIFs).
Optionally, you can try the more advanced method of making custom packs, but it can be more effort than worth.

Here's an example of a command to add Mickey Mouse: Lovely Smile pack (https://store.line.me/stickershop/product/1917/en):

magane.appendPack(`Mickey Mouse: Lovely Smile`, 37788, 40, false) 

What you need to pay attention to here are firstid, which is 37788, AND count, which is40.

firstid is the ID of the first sticker in the pack.
To get this ID, you would have to use your browser's Inspect Element feature on the first sticker.

Screenshot

With it, you should see something like this (don't worry if some strings aren't the exact same):

Screenshot

Look at the line that says https://stickershop.line-scdn.net/stickershop/v1/sticker/..., the ID is the numbers right afterwards, which is 37788.

Screenshot

As for count, it's the count of how many stickers there are in the pack.
For this you would have to count them manually, or you can choose to run this one-liner script in your browser's Console:

document.querySelectorAll('.mdCMN09Li').length

The said pack should have 40 stickers.

Screenshot

So after running the said command in your Discord app's Console, you should see something like this:

Screenshot

After adding a pack, you still need to subscribe to it from the subscription menu to start using them:

Screenshot

Too complicated?

You can try using this userscript instead: https://greasyfork.org/en/scripts/373429-line-append-string/code.
However you'd need a browser extension that lets you install userscripts, such as Tampermonkey, Greasemonkey, etc.

With it, you will be able to see something like this on every sticker pages:

Screenshot

Then you can simply run the line after Console command: in your Discord's console, and you're almost done! (don't forget you still need to subscribe to the pack from the subscription menu)

magane.appendCustomPack(title, id, count, animated, template)

This one is for the more advanced users.

You can use this to add your own custom packs that are hosted anywhere else, as long as the stickers can be hotlinked.

An example to add one of my custom packs, Azur Lane Pixel Stickers:

magane.appendCustomPack('Azur Lane Pixel Stickers', 'k9HCOlIRkV', 15, true, 'https://i.fiery.me/stickers/%pack%/%id%')

What you need to pay attention to here are id, which is k9HCOlIRkV, then count, which is 15, AND finally template, which is https://i.fiery.me/stickers/%pack%/%id%.

Template is the template URL to where the stickers can be downloaded.
Magane will replace %pack% with the ID (k9HCOlIRkV), and %id% with the individual sticker's IDs + extension name.
Magane expects the individual sticker IDs to be 1, 2, ..., n, a regular one-based index.

The extension name needs to be .png if not animated, OR .gif if otherwise.
In the example above, I have it as true because the pack is indeed animated.
Custom packs cannot mix extension names, so a pack can only be either fully animated OR not.

So for the example above, Magane expects the stickers to be hosted at https://i.fiery.me/stickers/k9HCOlIRkV/, and the individual stickers are named as 1.gif, 2.gif, ..., 15.gif.

Don't forget that after adding a pack, you still need to subscribe to it from the subscriptions menu to start using them.

magane.deletePack(id)

This is used to delete custom packs.

Now there's another thing that you need to pay attention to!

For packs that you added with magane.appendPack(), their internal IDs are startswith-<firstid>, where <firstid> is the ID of the first sticker in the pack.
So for the example Mickey Mouse pack, its ID would be startswith-37788.

For packs that you added with magane.appendCustomPack(), their internal IDs are custom-<id>, where <id> is the ID you initially input in the function.
So for the example Azur Lane Pixel Stickers pack, its ID would be custom-k9HCOlIRkV.

So for example, when you want to delete the Mickey Mouse pack, you'd run:

magane.deletePack('startswith-37788')

magane.searchPacks(keyword)

This is a helper function to search for added packs.

It will return their internal data structure, such as their internal ID, the stickers' file names, etc.

keyword is the search keyword, and needs to be a string.

So for example, to search for the Mickey Mouse pack, you can do any of these:

magane.searchPacks('mouse')
// or
magane.searchPacks('mickey mouse')
// or
magane.searchPacks('lovely') // remember, the pack's name is "Mickey Mouse: Lovely Smile"

Bonus: Custom packs

Here is my collection of custom packs: https://gist.github.com/BobbyWibowo/666f45d386594df0c4f58edce367d67b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment