mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-01 14:45:43 -05:00
added support for extras, added auth for SkiBot and more
This commit is contained in:
@@ -18,7 +18,7 @@ class command_handler {
|
||||
|
||||
if (!plainMessage?.startsWith(prefix)) return;
|
||||
const command = plainMessage.substring(prefix.length);
|
||||
|
||||
|
||||
const source = new CommandSource(
|
||||
data.sender,
|
||||
{ discord: false, console: false },
|
||||
@@ -27,16 +27,11 @@ class command_handler {
|
||||
);
|
||||
|
||||
source.sendFeedback = (message) => {
|
||||
if (source.sources.console) bot.console.command();
|
||||
else if (source.sources.discord) {
|
||||
return message; // lazy
|
||||
} else {
|
||||
if (options.mode === "savageFriends") bot.tellraw(`@a[name=${source.player.profile.name}]`, [
|
||||
if (options.mode === "savageFriends") bot.tellraw(`@a[name=${source.player.profile.name}]`, [
|
||||
message
|
||||
])
|
||||
else bot.tellraw(`@a[name="${source.player.profile.name}"]`, message)
|
||||
}
|
||||
};
|
||||
])
|
||||
else bot.tellraw(`@a[name="${source.player.profile.name}"]`, message)
|
||||
}
|
||||
|
||||
if (command.split(" ")[1] === bot.validation.trusted)
|
||||
source.player.hash = "trusted";
|
||||
@@ -59,6 +54,40 @@ class command_handler {
|
||||
console.log(e.stack);
|
||||
}
|
||||
});
|
||||
|
||||
bot.on('packet.custom_payload', (packet) => {
|
||||
if (packet.channel === "extras:message") {
|
||||
try {
|
||||
const decoded = packet.data.toString('ascii');
|
||||
const prefixes = config.prefixes
|
||||
const string = decoded.substring(20)
|
||||
const channel = packet.data.toString('ascii').split('\x05')[0]
|
||||
if (channel === config.skibot.channel) return
|
||||
const parsed = JSON.parse(string)
|
||||
const args = parsed.message
|
||||
const uuid = parsed.player
|
||||
prefixes.map((prefix) => {
|
||||
if (!args?.startsWith(prefix)) return;
|
||||
const command = args.substring(prefix.length)
|
||||
const sender = bot.players.find((e) => e.uuid === uuid)
|
||||
|
||||
const source = new CommandSource(
|
||||
sender,
|
||||
{ discord: false, console: false },
|
||||
'extras:message',
|
||||
null,
|
||||
)
|
||||
console.log(source.player.profile.name)
|
||||
source.sendFeedback = (message) => {
|
||||
bot.tellraw(`@a[name="${source.player.profile.name}"]`, message)
|
||||
}
|
||||
bot.commandManager.executeString(source, command)
|
||||
})
|
||||
} catch (e) {
|
||||
bot.console.error(e.toString())
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
module.exports = command_handler;
|
||||
module.exports = command_handler;
|
||||
Reference in New Issue
Block a user