Skip to content

Instantly share code, notes, and snippets.

@Mm2PL
Last active April 7, 2021 11:35
Show Gist options
  • Save Mm2PL/4ca2bfbcf8d6d7fd9f50756b47e0961b to your computer and use it in GitHub Desktop.
Save Mm2PL/4ca2bfbcf8d6d7fd9f50756b47e0961b to your computer and use it in GitHub Desktop.

To compile yourself use make_donk.js mods.js, make sure to install all dependancies before :).

Precompiled aliases:

$alias edit _mods dankdebug function:"const a={u:'user',c:'command',C:'channel',i:'invocation',t:'type'};let b={},c=null;for(const d of args)d.startsWith('-')?c=d.replace(/-+/,''):c&&(c=a[c]??c,b[c]=d,c=null);`null>${b.un?'un':''}ban ${Object.entries(b).map(([a,b])=>`${a}:${b}`).join(' ')}`" ${0+}
$alias add ban pipe alias run _mods ${0+}|pipe
$alias add unban pipe alias run _mods --un 1 ${0+}|pipe
const babel = require("@babel/core");
const fs = require("fs");
const fname = process.argv[process.argv.length - 1];
const code = fs.readFileSync(fname).toString();
let minified = babel.transform(code, {
plugins: [
"transform-minify-booleans", "minify-builtins", "transform-inline-consecutive-adds", "minify-constant-folding",
"minify-flip-comparisons", "minify-guarded-expressions", "minify-infinity", "minify-mangle-names",
"transform-member-expression-literals", "transform-merge-sibling-variables", "minify-numeric-literals",
"transform-property-literals", "transform-regexp-constructors", "transform-remove-console",
"transform-remove-debugger", "minify-simplify", "transform-simplify-comparison-operators",
"minify-type-constructors", "transform-undefined-to-void"
],
compact: 'auto',
sourceType: 'script',
minified: true,
comments: false,
}).code;
const alias_name = fname.replace(".js", "");
const escaped_minified = minified
.replace(/^\(\(\)=>{/, "")
.replace(/}\)\(\);$/, "")
.replace(/\\/g, "\\\\")
.replace(/'/g, '\\"')
.replace(/"/g, "'");
let new_minified = `$alias edit _${alias_name} dankdebug function:"${escaped_minified}" \${0+}`;
// minified = minified.replace(/^\(\(\)=>{/, `$alias edit _${alias_name} dankdebug `);
// minified = minified.replace(/}\)\(\);$/, ` arguments:"[\\"$\{0+\}\\"]"`);
// minified += `\n$alias edit ${alias_name} pipe alias run _${alias_name} \${0+}|pipe`;
new_minified += `\n$alias edit ${alias_name} pipe alias run _${alias_name} \${0+}|pipe`;
console.log(new_minified);
fs.writeFileSync(`${alias_name}.min`, new_minified);
(() => {
const short_options = {
u: "user",
c: "command",
C: "channel",
i: "invocation",
t: "type"
};
let data = {};
let next = null;
for (const arg of args) {
if (arg.startsWith('-')) {
next = arg.replace(/-+/, '');
} else if (next) {
next = short_options[next] ?? next;
data[next] = arg;
next = null;
}
}
`null>${data.un ? "un" : ""}ban ${Object.entries(data).map(([k, v]) => `${k}:${v}`).join(' ')}`;
})();
{
"dependencies": {
"babel": "^6.23.0",
"babel-minify": "^0.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment