-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (27 loc) · 858 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const { Plugin } = require("powercord/entities");
const { React } = require("powercord/webpack");
const { resolve } = require("path");
const Settings = require("./Settings");
module.exports = class Alias extends Plugin {
async startPlugin () {
this.registerSettings(
"alias",
"Alias",
Settings
);
this.loadCSS(resolve(__dirname, "style.css"));
this.registerCommand(
"alias",
["a"],
"Paste pre-set text for a given name.",
"{c} [ alias name ]",
(args) => ({
send: true,
result: this.settings.get("pairs", []).filter(this.unique).find(p => p[0] == args[0])[1] + (args.length > 0 ? (" " + args.splice(1, args.length - 1).join(" ")) : "")
})
);
}
unique(value, index, self) {
return self.filter(function(v, k, t) { return v[0] === value }).length <= 1;
}
};