mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-03 07:35:39 -05:00
v6.1.2, build: 1200
This commit is contained in:
+9
-3
@@ -1,4 +1,8 @@
|
||||
function boot (bot, options, discordClient, config) {
|
||||
|
||||
function boot (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
bot.on("packet.login", (data) => {
|
||||
if (bot.options.isCreayun) return
|
||||
if (new Date().getDay() === 5) {
|
||||
@@ -6,7 +10,9 @@ function boot (bot, options, discordClient, config) {
|
||||
} else {
|
||||
bot.chat.message('&9FNF&3Boyfriend&1Bot &fcreated by &4Parker&02991');
|
||||
}
|
||||
}) // &9 &3 &1
|
||||
})
|
||||
setInterval(() => {
|
||||
process.stdout.write(`\x1b]2; FNFBoyfriendBot | Time: ${new Date().toLocaleString("en-US",{timeZone: "America/CHICAGO"})} | \x1b\x5c`)
|
||||
}, 1000)
|
||||
}
|
||||
module.exports = boot;
|
||||
|
||||
|
||||
+5
-2
@@ -12,8 +12,11 @@ function tryParse (json) {
|
||||
return { text: '' }
|
||||
}
|
||||
}
|
||||
//what was changed??
|
||||
function chat (bot, options, config) {
|
||||
//what was changed?
|
||||
function chat (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
let ChatMessage
|
||||
bot.on('registry_ready', registry => {
|
||||
ChatMessage = loadPrismarineChat(registry)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const CommandSource = require('../util/command_source');
|
||||
module.exports = (bot, options, config) => {
|
||||
module.exports = (context) => {
|
||||
let ratelimit = 0;
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
bot.on("parsed_message", (data) => {
|
||||
if (data.type !== "minecraft:chat") return;
|
||||
const prefixes = config.prefixes;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const mcData = require('minecraft-data')('1.20.2');
|
||||
function core (bot, options, config) {
|
||||
let number = 0;
|
||||
|
||||
function core (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
bot.core = {
|
||||
area: {
|
||||
start: config.core?.area.start ?? { x: 0, y: 0, z: 0 },
|
||||
@@ -26,8 +29,9 @@ function core (bot, options, config) {
|
||||
it will not refill core until the pos is not NaN
|
||||
instead of tping to a set cords cuz fuck you im not doing that
|
||||
*/
|
||||
const command = `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'} destroy`
|
||||
if (config.core.method === 'chat') {
|
||||
bot.chat.command(`minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'}`)
|
||||
bot.chat.command(`${command}`)
|
||||
} else if (config.core.method === 'item') {
|
||||
bot._client.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
@@ -35,8 +39,7 @@ function core (bot, options, config) {
|
||||
present: true,
|
||||
itemId: mcData.itemsByName.command_block.id,
|
||||
itemCount: 1,
|
||||
nbtData: {
|
||||
}
|
||||
nbtData: { }
|
||||
}
|
||||
});
|
||||
|
||||
@@ -66,7 +69,7 @@ function core (bot, options, config) {
|
||||
|
||||
bot._client.write('update_command_block', {
|
||||
location: bot.position,
|
||||
command: `minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${JSON.stringify(config.core.name)}'}`,
|
||||
command,
|
||||
flags: 5,
|
||||
mode: 1
|
||||
})
|
||||
@@ -124,6 +127,43 @@ function core (bot, options, config) {
|
||||
bot.core.incrementCurrentBlock();
|
||||
}
|
||||
},
|
||||
|
||||
runTracked (command) {
|
||||
const transactionId = Math.floor(Math.random() * 1000);
|
||||
const location = bot.core.currentBlock();
|
||||
if (!location) return;
|
||||
|
||||
if (bot.position.y !== bot.core.position.y) {
|
||||
bot.chat.command(`minecraft:tp ${bot.core.position.x} ${bot.core.position.y} ${bot.core.position.z}`)
|
||||
}
|
||||
|
||||
bot._client.write('update_command_block', {
|
||||
command: command.substring(0, 32767),
|
||||
location,
|
||||
flags: 5,
|
||||
mode: 1,
|
||||
// LastOutput: true,
|
||||
});
|
||||
|
||||
bot.core.incrementCurrentBlock();
|
||||
|
||||
bot._client.write('query_block_nbt', {
|
||||
location,
|
||||
transactionId
|
||||
});
|
||||
|
||||
bot.on('packet.nbt_query_response', (data) => {
|
||||
// transactionId,
|
||||
try {
|
||||
if (data.transactionId === transactionId) {
|
||||
bot.tellraw("@a", require('util').inspect(data.value))
|
||||
bot.tellraw("@a", JSON.stringify(data.value))
|
||||
}
|
||||
} catch (e) {
|
||||
bot.tellraw("@a", require("util").inspect(e.stack));
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (bot.options.isSavage || bot.options.isCreayun) return
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
function command_loop (bot, options, config) {
|
||||
function command_loop (context) {
|
||||
const bot = context.bot;
|
||||
bot.cloop = {
|
||||
list: [],
|
||||
add (command, interval) {
|
||||
|
||||
@@ -3,7 +3,12 @@ const path = require('path');
|
||||
const CommandError = require('../util/command_error.js');
|
||||
const CommandSource = require('../util/command_source');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
async function command_manager (bot, options, config, discordClient) {
|
||||
|
||||
async function command_manager (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const discordClient = context.discordClient;
|
||||
const options = context.options;
|
||||
bot.commandManager = {
|
||||
commands: {},
|
||||
commandlist: [],
|
||||
@@ -43,29 +48,45 @@ async function command_manager (bot, options, config, discordClient) {
|
||||
]
|
||||
})?.toAnsi())
|
||||
}
|
||||
if (command?.data?.trustLevel > 0) {
|
||||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
if (command?.data?.trustLevel === 1 && !source?.sources?.discord) {
|
||||
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide a trusted, admin or owner hash", color: "dark_red" })
|
||||
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted, admin or owner hash', color: 'dark_red' });
|
||||
} else if (command?.data?.trustLevel === 1 && source?.sources.discord) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
|
||||
|
||||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
switch (command?.data?.trustLevel) {
|
||||
case 0:
|
||||
// do nothing since trust level 0 is public
|
||||
break;
|
||||
case 1:
|
||||
if (source?.sources?.discord) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
|
||||
}
|
||||
if (command?.data?.trustLevel === 2 && !source.sources.console) {
|
||||
if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash", color: 'dark_red' })
|
||||
if (args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' });
|
||||
}
|
||||
if (command?.data?.trustLevel === 3 && !source.sources.discord && !source.sources.console) {
|
||||
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" })
|
||||
if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' })
|
||||
} else if (command?.data?.trustLevel === 3 && source.sources.discord && !source.sources.console) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" })
|
||||
} else if (command?.data?.trustLevel === 4 && !source.sources.console) {
|
||||
throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" });
|
||||
}
|
||||
} else if (!source?.sources.console) {
|
||||
if (args.length === 0) throw new CommandError({ text: "Please provide a trusted, admin or owner hash", color: "dark_red" });
|
||||
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid trusted, admin or owner hash', color: 'dark_red' });
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (source?.sources?.discord) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.admin}` || role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
|
||||
} else if (!source?.sources?.console) {
|
||||
if (args.length === 0) throw new CommandError({ text: "Please provide an admin or owner hash", color: 'dark_red' })
|
||||
if (args[0] !== bot.validation.admin && args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid admin or owner hash', color: 'dark_red' });
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (source?.sources?.discord) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" })
|
||||
} else if (!source?.sources?.console) {
|
||||
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" })
|
||||
if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' })
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (!source?.sources?.console) {
|
||||
throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" })
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!command?.discordExecute && command && source?.sources?.discord) {
|
||||
throw new CommandError(`${command.name} command is not supported in discord!`)
|
||||
@@ -81,7 +102,7 @@ async function command_manager (bot, options, config, discordClient) {
|
||||
if (source?.sources?.discord && !source?.sources?.console) {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(`${config.colors.discord.error}`)
|
||||
.setTitle(`${command?.name} command`)
|
||||
.setTitle(`${command?.data?.name} command`)
|
||||
.setDescription(`\`\`\`${error}\`\`\``)
|
||||
bot?.discord?.message?.reply({
|
||||
embeds: [
|
||||
|
||||
+6
-32
@@ -1,6 +1,10 @@
|
||||
const CommandSource = require('../util/command_source');
|
||||
const prismarineChat = require('prismarine-chat')('1.20.2');
|
||||
function Console (bot, options, config) {
|
||||
|
||||
function Console (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
let ratelimit = 0;
|
||||
bot.console = {
|
||||
readline: null,
|
||||
@@ -101,39 +105,9 @@ function Console (bot, options, config) {
|
||||
bot.on('actionBar', (message) => {
|
||||
if (!options.logging) return;
|
||||
if (ratelimit > 10) return
|
||||
// bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi());
|
||||
bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi());
|
||||
bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`);
|
||||
ratelimit++
|
||||
})
|
||||
|
||||
/*
|
||||
setInterval(() => spamCount = 0, 1000 * 2)
|
||||
|
||||
bot.on('message', message => {
|
||||
if (spamCount > 300) {
|
||||
console.log('WTF spam detected not logging')
|
||||
return
|
||||
}
|
||||
|
||||
const ansi = bot.getMessageAsPrismarine(message)?.toAnsi()
|
||||
const string = bot.getMessageAsPrismarine(message)?.toString()
|
||||
const now = new Date().toLocaleString()
|
||||
|
||||
|
||||
spamCount++
|
||||
*/
|
||||
|
||||
/* bot.on('message', (message) => {
|
||||
rateLimit++
|
||||
setTimeout(() => {
|
||||
rateLimit--
|
||||
}, 1000)
|
||||
if (!options.logging) return;
|
||||
if (rateLimit > 100) {
|
||||
return
|
||||
}
|
||||
bot.console.log(bot.getMessageAsPrismarine(message)?.toAnsi());
|
||||
bot.console.fileLogger(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ${bot.getMessageAsPrismarine(message)?.toString()}`);
|
||||
})*/
|
||||
}
|
||||
module.exports = Console;
|
||||
|
||||
@@ -6,8 +6,11 @@ const CommandSource = require('../util/command_source')
|
||||
|
||||
//const client = new Client({ intents: [Guilds, GuildMessages, MessageContent] })
|
||||
const util = require('util')
|
||||
|
||||
function discord(bot, options, config, discordClient) {
|
||||
function discord (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const discordClient = context.discordClient;
|
||||
const options = context.options;
|
||||
if (!options?.channelId) {
|
||||
bot.discord = {
|
||||
invite: config.discord?.invite
|
||||
@@ -82,7 +85,7 @@ function discord(bot, options, config, discordClient) {
|
||||
if (message.content.startsWith(config.discord.prefix)) { // TODO: Don't hardcode this
|
||||
const source = new CommandSource({
|
||||
profile: {
|
||||
name: message?.member?.displayName
|
||||
name: `${message?.member.nickname || message?.author.displayName}`
|
||||
}
|
||||
}, {
|
||||
discord: true,
|
||||
@@ -132,7 +135,7 @@ function discord(bot, options, config, discordClient) {
|
||||
}
|
||||
},
|
||||
{
|
||||
text: message?.member?.displayName
|
||||
text: `${message.member.nickname || message.author.displayName}`,
|
||||
},
|
||||
message.content
|
||||
]
|
||||
|
||||
@@ -3,7 +3,10 @@ const path = require("path");
|
||||
const { createGzip } = require("zlib");
|
||||
const readline = require('readline');
|
||||
const { Console } = require("console");
|
||||
function fileLogger(bot, options, message) {
|
||||
function fileLogger(context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
const currentDate = new Date();
|
||||
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1)
|
||||
.toString()
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
const os = require('os');
|
||||
module.exports = (context) => {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
let timer;
|
||||
bot.memUsage = {
|
||||
enabled: false
|
||||
}
|
||||
|
||||
timer = setInterval(() => {
|
||||
component = {
|
||||
translate: "%s%s%s %s | %s: %s%s / %s%s | %s: %s%s / %s%s |",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: "FNF", color: "dark_blue" },
|
||||
{ text: "Boyfriend", color: "dark_aqua" },
|
||||
{ text: "Bot", color: "blue" },
|
||||
{ text: "Memory Usage" },
|
||||
{ text: "Free Server Memory", color: config.colors.commands.primary },
|
||||
{ text: `${Math.floor(os.freemem() / 1048576)}`, color: config.colors.integer },
|
||||
{ text: "MiB", color: config.colors.commands.secondary },
|
||||
{ text: `${Math.floor(os.totalmem() / 1048576)}`, color: config.colors.integer },
|
||||
{ text: "MiB", color: config.colors.commands.secondary },
|
||||
{ text: "Bot Memory Usage", color: config.colors.commands.primary },
|
||||
{ text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`, color: config.colors.integer },
|
||||
{ text: "MiB", color: config.colors.commands.secondary },
|
||||
{ text: `${Math.floor(process.memoryUsage().heapTotal / 1048576 )}`, color: config.colors.integer },
|
||||
{ text: "MiB", color: config.colors.commands.secondary }
|
||||
]
|
||||
}
|
||||
if (!bot.memUsage.enabled) return;
|
||||
bot.core.run(`minecraft:title @a[tag=!memusage] actionbar ${JSON.stringify(component)}`)
|
||||
}, 100)
|
||||
bot.on('end', () => {
|
||||
bot.memUsage.enabled = false;
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
function player_list (bot, options, config) {
|
||||
function player_list (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
bot.players = []
|
||||
|
||||
bot.on('packet.player_info', async (packet) => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
function position (bot, options, config) {
|
||||
|
||||
function position (context) {
|
||||
const bot = context.bot;
|
||||
bot.position = null
|
||||
|
||||
bot.on('packet.position', packet => {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const mc = require('minecraft-protocol');
|
||||
const usernameGen = require("../util/usernameGen");
|
||||
function reconnect (bot, options, config) {
|
||||
function reconnect (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
bot.on('end', () => {
|
||||
//bot = undefined;
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
function selfcare (bot, options, config) {
|
||||
function selfcare (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
let entityId;
|
||||
let permissionLevel = 2;
|
||||
let unmuted = false;
|
||||
@@ -62,7 +65,7 @@ You already have registered this username!
|
||||
else if (stringMessage?.startsWith("Successfully set your username to ")) username = true
|
||||
else if (stringMessage === `You already have the username "${bot.username}"`) username = false
|
||||
else if (stringMessage === `You no longer have a nickname.`) nickname = false;
|
||||
else if (stringMessage.startsWith('Your nickname is now ')) nickname = true;
|
||||
else if (stringMessage?.startsWith('Your nickname is now ')) nickname = true;
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
+15
-14
@@ -1,16 +1,17 @@
|
||||
module.exports = (bot) => {
|
||||
// let aaa cook
|
||||
bot.tab_complete = (str) => {
|
||||
return new Promise((resolve) => {
|
||||
bot._client.write('tab_complete', {
|
||||
text: str, assumeCommand: false, sendBlockInSight: false
|
||||
})
|
||||
const tab_completeH = (packet) => {
|
||||
bot._client.removeListener('tab_complete', tab_completeH)
|
||||
|
||||
resolve(packet.matches)
|
||||
}
|
||||
bot._client.once('tab_complete', tab_completeH)
|
||||
})
|
||||
}
|
||||
module.exports = (context) => {
|
||||
const bot = context.bot;
|
||||
// let aaa cook
|
||||
bot.tab_complete = (str) => {
|
||||
return new Promise((resolve) => {
|
||||
bot._client.write('tab_complete', {
|
||||
text: str, assumeCommand: false, sendBlockInSight: false
|
||||
})
|
||||
const tab_completeH = (packet) => {
|
||||
bot._client.removeListener('tab_complete', tab_completeH)
|
||||
resolve(packet.matches)
|
||||
}
|
||||
bot._client.once('tab_complete', tab_completeH)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
const crypto = require('crypto')
|
||||
function validation (bot, options, config) {
|
||||
function validation (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
setInterval(() => {
|
||||
bot.validation = {
|
||||
trusted: crypto.createHash('sha256').update(Math.floor(Date.now() / 1000) + config.keys.trusted).digest('hex').substring(0, 16),
|
||||
|
||||
Reference in New Issue
Block a user