You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
739 B

function init(obj) {
obj.demon.__commands = {}
demon.patcher.after("sendMessage", demon.webpack.findByProps("sendMessage"),
(otherRes, args) => {
let res;
for (const key of Reflect.ownKeys(obj.demon.__commands)) {
let command = obj.demon.__commands[key]
if (args[1].content.split(" ")[0] === ">" + command.name) {
res = command.callback(args)
break
}
}
if (res !== undefined) args[1].content = res
return args
}
)
}
// command = {
// name: "name",
// callback: (args)=>"Hello, world!"
// }
function add(command) {
let sym = Symbol(command.name);
window.demon.__commands[sym] = command;
return () => {
delete window.demon.__commands[sym];
}
}
export default {
add: add,
init: init
}