forked from afspiegeling/NitoriBot
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
639a2b0eaa | ||
|
|
f60f5c4a15 | ||
|
|
572e09989c | ||
|
|
ad4f35bb4c | ||
|
|
e655f831d3 |
Generated
+7
-4
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"name": "FridayNightFunkinBoyfriendBot",
|
||||
"version": "v6.1.1-1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"build": "1150",
|
||||
"codename": "",
|
||||
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot",
|
||||
"buildstring": {
|
||||
"version": "v6.1.3",
|
||||
"build": "1210",
|
||||
"releaseDate": "12/06/24",
|
||||
"codename": "",
|
||||
"url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot"
|
||||
},
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
this folder is for removed / scrapped concepts just in case people want to reimplement them
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
const trustedPlayers = require('../data/trustedPlayers.json');
|
||||
module.exports = (bot, options, config) => {
|
||||
let component;
|
||||
trustedPlayers.map((trusted) => {
|
||||
/*component.push({
|
||||
translate: "%s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: "ea" }
|
||||
]
|
||||
})*/
|
||||
bot.on('message', (data) => {
|
||||
try {
|
||||
let stringMessage = bot.getMessageAsPrismarine(data)?.toString();
|
||||
// console.log(JSON.stringify(data))
|
||||
// console.log(data?.with[0]?.clickEvent);
|
||||
// console.log(data.color);
|
||||
// for (const players of bot.players) {
|
||||
if (
|
||||
/*
|
||||
stringMessage.startsWith(`${trusted.player}`) &&
|
||||
data.translate === "multiplayer.player.joined" &&
|
||||
data.color === "yellow" &&
|
||||
data.with.insertion === `${trusted.player}` &&
|
||||
data?.with[0]?.clickEvent === `{action:'suggest_command',value:'/tell ${trusted.player} '}` &&*/
|
||||
JSON.stringify(data) ===
|
||||
JSON.stringify({
|
||||
color:'yellow',
|
||||
translate:'multiplayer.player.joined',
|
||||
with:[{insertion:`${trusted.player}`,
|
||||
clickEvent:{
|
||||
action:'suggest_command',
|
||||
value:`/tell ${trusted.player} `
|
||||
},
|
||||
hoverEvent:{
|
||||
action:'show_entity',
|
||||
contents:{
|
||||
type:'minecraft:player',
|
||||
id:`${bot.players.find((player) => player.profile.name === trusted.player)?.uuid}`,
|
||||
name:{
|
||||
text:`${trusted.player}`
|
||||
}
|
||||
}
|
||||
},
|
||||
text:`${trusted.player}`
|
||||
}]
|
||||
})
|
||||
) {
|
||||
if (bot.players.map((e) => { e.profile.name === trusted.player })) {
|
||||
bot.tellraw(`@a[name="${trusted.player}"]`, "e");
|
||||
component = "e";
|
||||
}
|
||||
}
|
||||
// bot.tellraw(`@a[name="${bot.players.find((player) => player.profile.name === trusted.player).profile.name}"]`, component);
|
||||
/* for (const players of bot.players) {
|
||||
// console.log(players);
|
||||
if (players.profile.name === trusted.player) {
|
||||
let e = players.profile.name === trusted.player;
|
||||
for (const eachBot of bot.bots) {
|
||||
eachBot.tellraw(`@a[name="${trusted.player}"]`, "e");
|
||||
}
|
||||
}*/
|
||||
// }
|
||||
//if (bot.players.find((player) => player.profile.name !== trusted.player)) return
|
||||
//for (const eachBot of bot.bots) {
|
||||
// if (bot.players.find((player) => player.profile.name === trusted.player)) {
|
||||
// bot.tellraw(`@a[name="${bot.players.find((player) => player.profile.name === trusted.player).profile.name}"]`, "e");
|
||||
// }
|
||||
//}
|
||||
// bot.chat.message(`${trusted.player} joined the game`);
|
||||
// }
|
||||
// }
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
})
|
||||
})
|
||||
/* bot.on('packet.login', (data) => {
|
||||
console.log(bot.players.find((players) => players.profile.name === trusted.player))
|
||||
console.log(bot.players)
|
||||
if (bot.players.find((player) => player.profile.name === trusted.player)) {
|
||||
bot.chat.message('player joined the game')
|
||||
}
|
||||
})
|
||||
multiplayer.player.joined
|
||||
[{"insertion":"Parker2991","clickEvent":{"action":"suggest_command",
|
||||
"value":"/tell Parker2991 "},"hoverEvent":{"action":"show_entity",
|
||||
"contents":{"type":"minecraft:player",
|
||||
"id":"85f5b68d-a567-3877-9701-3cd7404bc9d9",
|
||||
"name":{"text":"Parker2991"}}},"text":"Parker2991"}]
|
||||
[
|
||||
{
|
||||
insertion: 'Parker2991',
|
||||
clickEvent: { action: 'suggest_command', value: '/tell Parker2991 ' },
|
||||
hoverEvent: { action: 'show_entity', contents: [Object] },
|
||||
text: 'Parker2991'
|
||||
}
|
||||
]
|
||||
yellow
|
||||
*/
|
||||
/*for (const trusted in trustedPlayers) {
|
||||
component.push({
|
||||
translate: '%s',
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: 'e' }
|
||||
]
|
||||
})
|
||||
// console.log(component)
|
||||
}*/
|
||||
|
||||
// bot.tellraw("@a", component)
|
||||
|
||||
}
|
||||
+21
-10
@@ -2,9 +2,9 @@ const mc = require('minecraft-protocol');
|
||||
const { EventEmitter } = require('events');
|
||||
EventEmitter.defaultMaxListeners = 5e6;
|
||||
const util = require('util');
|
||||
const createRegistry = require('prismarine-registry');
|
||||
const ChatMessage = require('prismarine-chat');
|
||||
function createBot(options = {}, config) {
|
||||
let endCount = 0;
|
||||
const bot = new EventEmitter();
|
||||
bot.options = {
|
||||
// Set some default values in options
|
||||
@@ -17,15 +17,15 @@ function createBot(options = {}, config) {
|
||||
bot.on('init_client', client => {
|
||||
client.on('packet', (data, meta) => {
|
||||
bot.emit('packet', data, meta)
|
||||
bot.emit('packet.' + meta.name, data)
|
||||
bot.emit('packet.' + meta.name, data);
|
||||
})
|
||||
|
||||
client.on('login', () => {
|
||||
client.on('login', (data) => {
|
||||
bot.uuid = client.uuid
|
||||
bot.username = client.username
|
||||
bot.registry = createRegistry(client.version)
|
||||
bot.registry = require('prismarine-registry')(client.version);
|
||||
bot.registry.language = require('./data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
bot.emit('registry_ready', bot.registry);
|
||||
})
|
||||
|
||||
client.on('disconnect', data => {
|
||||
@@ -36,14 +36,21 @@ function createBot(options = {}, config) {
|
||||
client.on('end', reason => {
|
||||
bot.emit('end', reason);
|
||||
if (reason === "socketClosed") return;
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch(`§8[§bClient Reconnect§8]§r ${reason}`)?.toAnsi())
|
||||
// bot = undefined;
|
||||
// config = undefined;
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch(`§8[§bClient Reconnect§8]§r ${reason}`)?.toAnsi());
|
||||
})
|
||||
|
||||
client.on('error', error => {
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
|
||||
bot?.discord?.channel?.send(error.toString())
|
||||
endCount++
|
||||
if (endCount === 10) {
|
||||
bot.console.info('stopped logging disconnect messages for now...');
|
||||
bot?.discord?.channel?.send('stopped logging disconnect messages for now...');
|
||||
return;
|
||||
} else if (endCount > 10) {
|
||||
return;
|
||||
} else {
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
|
||||
bot?.discord?.channel?.send(error.toString());
|
||||
}
|
||||
})
|
||||
|
||||
client.on("keep_alive", ({ keepAliveId }) => {
|
||||
@@ -56,6 +63,10 @@ function createBot(options = {}, config) {
|
||||
bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||
})
|
||||
|
||||
client.on('success', (data) => {
|
||||
endCount = 0;
|
||||
})
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
// console?.warn(e.stack)
|
||||
});
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
const CommandError = require('../../util/command_error');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
name: 'coresettings',
|
||||
trustLevel: 2,
|
||||
aliases: [
|
||||
"cbsettings"
|
||||
],
|
||||
description: 'change the bots core settings',
|
||||
usages: [
|
||||
"useplacedcommandblock <on/off/true/false/enable/disable>",
|
||||
"area start <positions>",
|
||||
"area end <positions>",
|
||||
"refillmethod/rcmethod <item/chat>"
|
||||
],
|
||||
},
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const args = context.arguments;
|
||||
const config = context.config;
|
||||
if (!args && !args[0] && !args[1] && !args[2] && !args[3] && !args[4] && !args[5]) return;
|
||||
switch (args[1]?.toLowerCase()) {
|
||||
case "useplacedcommandblock":
|
||||
switch (args[2]?.toLowerCase()) {
|
||||
case "on":
|
||||
case "true":
|
||||
case "enable":
|
||||
bot.core.usePlacedCommandBlock = true;
|
||||
bot.chat.message('now using the placed command block');
|
||||
break;
|
||||
case "off":
|
||||
case "false":
|
||||
case "disable":
|
||||
bot.core.usePlacedCommandBlock = false;
|
||||
bot.chat.message('no longer using the placed command block');
|
||||
break;
|
||||
default:
|
||||
if (bot.core.usePlacedCommandBlock) {
|
||||
bot.chat.message("the bot is currently using the placed command block to run its commands");
|
||||
} else {
|
||||
bot.chat.message("the bot is currently using its command block core to run its commands");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "area":
|
||||
switch (args[2]?.toLowerCase()) {
|
||||
case "start":
|
||||
if (isNaN(args[3]) || isNaN(args[4]) || isNaN(args[5])) {
|
||||
bot.core.area.start = config.core.area.start;
|
||||
bot.chat.message("arguments were NaN, defaulting to config core start coords");
|
||||
} else {
|
||||
bot.core.area.start = {
|
||||
x: Number(args[3]),
|
||||
y: Number(args[4]),
|
||||
z: Number(args[5])
|
||||
};
|
||||
bot.chat.message(`setting core start pos to x: ${args[3]}, y: ${args[4]}, z: ${args[5]}`);
|
||||
}
|
||||
break;
|
||||
case "end":
|
||||
if (isNaN(args[3]) || isNaN(args[4]) || isNaN(args[5])) {
|
||||
bot.core.area.end = config.core.area.end;
|
||||
bot.chat.message("arguments were NaN, defaulting to config core end coords");
|
||||
} else {
|
||||
bot.core.area.end = {
|
||||
x: Number(args[3]),
|
||||
y: Number(args[4]),
|
||||
z: Number(args[5])
|
||||
};
|
||||
|
||||
bot.chat.message(`setting core end pos to x: ${args[3]}, y: ${args[4]}, z: ${args[5]}`);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bot.chat.message(`core start pos: x: ${bot.core.area.start.x}, y: ${bot.core.area.start.y}, z: ${bot.core.area.start.z}, and end pos: x: ${bot.core.area.end.x}, y: ${bot.core.area.end.y}, z: ${bot.core.area.end.z} `)
|
||||
}
|
||||
break;
|
||||
case "refillmethod":
|
||||
case "rcmethod":
|
||||
switch (args[2]?.toLowerCase()) {
|
||||
case "item":
|
||||
config.core.itemRefill = true;
|
||||
bot.chat.message('now refilling via item');
|
||||
break;
|
||||
case "chat":
|
||||
config.core.itemRefill = false;
|
||||
bot.chat.message('now refilling via chat');
|
||||
break;
|
||||
default:
|
||||
if (config.core.itemRefill) {
|
||||
bot.chat.message("currently filling core via item");
|
||||
} else {
|
||||
bot.chat.message("currently filling core via chat");
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new CommandError('invalid argument');
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -6,6 +6,7 @@ module.exports = {
|
||||
name: 'servereval',
|
||||
trustLevel: 3,
|
||||
aliases: [
|
||||
"se"
|
||||
],
|
||||
description: 'run code unisolated',
|
||||
usages: [
|
||||
@@ -25,7 +26,7 @@ module.exports = {
|
||||
} else if (bot.options.useChat || bot.options.isSavage) {
|
||||
bot.chat.message(bot.getMessageAsPrismarine({ text: util.inspect(eval(script), { stylize }).substring(0, 32700) })?.toMotd().replaceAll('§','&'))
|
||||
} else {
|
||||
bot.tellraw(`@a`, [
|
||||
bot.tellraw(`@a[name="${source.player.profile.name}"]`, [
|
||||
{
|
||||
text: util.inspect(eval(script), { stylize }).substring(0, 32700),
|
||||
hoverEvent: {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const CommandError = require('../../util/command_error')
|
||||
const sleep = require('../../util/sleep');
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
name: 'core',
|
||||
@@ -14,16 +14,10 @@ module.exports = {
|
||||
"<command>",
|
||||
],
|
||||
},
|
||||
async execute (context) {
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const message = context.arguments.join(' ');
|
||||
bot.core.run(message);
|
||||
await sleep(45);
|
||||
/* bot.on('commandBlockOutput', (packet) => {
|
||||
bot.tellraw("@a", require('util').inspect(packet));
|
||||
console.log(packet);
|
||||
})*/
|
||||
// bot.core.commandBlockOutput()
|
||||
},
|
||||
discordExecute (context) {
|
||||
const bot = context.bot;
|
||||
|
||||
@@ -348,12 +348,40 @@ module.exports = {
|
||||
setTimeout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(trusted)?.toMotd().replaceAll("§","&"));
|
||||
}, 400)
|
||||
setTimeout(() => {
|
||||
setTimexout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(admin)?.toMotd()?.replaceAll('§','&'))
|
||||
}, 400)
|
||||
setTimeout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(owner).toMotd().replaceAll("§","&"));
|
||||
}, 400)
|
||||
} else if (bot.options.isCreayun) {
|
||||
bot.chat.message(bot.getMessageAsPrismarine([
|
||||
{
|
||||
text: 'Commands (',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: length,
|
||||
color: 'gold'
|
||||
},
|
||||
{
|
||||
text: ') ',
|
||||
color: 'gray'
|
||||
},
|
||||
category,
|
||||
])?.toMotd().replaceAll('§','&'))
|
||||
setTimeout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(public)?.toMotd().replaceAll("§","&"))
|
||||
}, 2500)
|
||||
setTimeout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(trusted)?.toMotd().replaceAll("§","&"));
|
||||
}, 2500)
|
||||
setTimeout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(admin)?.toMotd()?.replaceAll('§','&'))
|
||||
}, 2500)
|
||||
setTimeout(() => {
|
||||
bot.chat.message(bot.getMessageAsPrismarine(owner).toMotd().replaceAll("§","&"));
|
||||
}, 2500)
|
||||
} else if (admin.length === 0) {
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
|
||||
{ text: 'Commands (', color: 'gray' },
|
||||
|
||||
+27
-27
@@ -46,7 +46,7 @@ module.exports = {
|
||||
switch (args[0]?.toLowerCase()) {
|
||||
case "about":
|
||||
component.push({
|
||||
text: `FNFBoyfriendBot is a kaboom bot created by Parker2991\nThe source code and changelog can be found here ${botInfo.url}`,
|
||||
text: `FNFBoyfriendBot is a kaboom bot created by Parker2991\nThe source code and changelog can be found here ${botInfo.buildstring.url}`,
|
||||
color: `${config.colors.commands.primary}`,
|
||||
translate: "",
|
||||
hoverEvent: {
|
||||
@@ -57,7 +57,7 @@ module.exports = {
|
||||
},
|
||||
clickEvent: {
|
||||
action: "open_url",
|
||||
value: `${botInfo.url}`
|
||||
value: `${botInfo.buildstring.url}`
|
||||
}
|
||||
})
|
||||
break;
|
||||
@@ -153,7 +153,7 @@ module.exports = {
|
||||
case "contributors":
|
||||
case "credits":
|
||||
component.push({
|
||||
translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s %s\n%s",
|
||||
translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s %s\n%s\n%s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: "Parker", color: "dark_red" },
|
||||
@@ -166,7 +166,8 @@ module.exports = {
|
||||
{ text: "aaa", color: "gold" },
|
||||
{ text: "Morgan", color: "green" },
|
||||
{ text: "Ankan", color: "dark_green" },
|
||||
{ text: "TurtleKid", color: "green" }
|
||||
{ text: "TurtleKid", color: "green" },
|
||||
{ text: "Ploat/ImGloriz", color: "#cd8ccb" },
|
||||
]
|
||||
})
|
||||
break;
|
||||
@@ -191,6 +192,7 @@ module.exports = {
|
||||
})
|
||||
break;
|
||||
case "usages":
|
||||
case "usage":
|
||||
switch (args.slice(1).join(' ')?.toLowerCase()) {
|
||||
case "bot":
|
||||
component.push({
|
||||
@@ -310,26 +312,7 @@ module.exports = {
|
||||
case "version":
|
||||
case "ver":
|
||||
if (botInfo.codename === '') {
|
||||
component.push({
|
||||
translate: "%s %s %s-%s-%s%s\n%s - %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: "Friday Night Funkin", color: "dark_blue" },
|
||||
{ text: "Boyfriend", color: "dark_aqua" },
|
||||
{ text: "Bot", color: "blue" },
|
||||
{ text: `${botInfo.version}`, color: config.colors.integer },
|
||||
{ text: "#" },
|
||||
{ text: `${botInfo.build}`, color: config.colors.integer },
|
||||
{ text: "11/22/22", color: config.colors.commands.primary },
|
||||
{ text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary },
|
||||
]
|
||||
})
|
||||
/*
|
||||
`§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-
|
||||
${botInfo.version}-#${botInfo.build}-${botInfo.codename}\n11/22/22 -
|
||||
${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}
|
||||
*/
|
||||
} else {
|
||||
|
||||
component.push({
|
||||
translate: "%s %s %s-%s-%s%s-%s\n%s - %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
@@ -337,10 +320,27 @@ ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}
|
||||
{ text: "Friday Night Funkin", color: "dark_blue" },
|
||||
{ text: "Boyfriend", color: "dark_aqua" },
|
||||
{ text: "Bot", color: "blue" },
|
||||
{ text: `${botInfo.version}`, color: config.colors.integer },
|
||||
{ text: `${botInfo.buildstring.version}`, color: config.colors.integer },
|
||||
{ text: "#" },
|
||||
{ text: `${botInfo.build}`, color: config.colors.integer },
|
||||
{ text: `${botInfo.codename}` },
|
||||
{ text: `${botInfo.buildstring.build}`, color: config.colors.integer },
|
||||
{ text: `${botInfo.buildstring.releaseDate}`, color: config.colors.commands.secondary },
|
||||
{ text: "11/22/22", color: config.colors.commands.primary },
|
||||
{ text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary },
|
||||
]
|
||||
})
|
||||
} else {
|
||||
component.push({
|
||||
translate: "%s %s %s-%s-%s%s-%s-%s\n%s - %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: "Friday Night Funkin", color: "dark_blue" },
|
||||
{ text: "Boyfriend", color: "dark_aqua" },
|
||||
{ text: "Bot", color: "blue" },
|
||||
{ text: `${botInfo.buildstring.version}`, color: config.colors.integer },
|
||||
{ text: "#" },
|
||||
{ text: `${botInfo.buildstring.build}`, color: config.colors.integer },
|
||||
{ text: `${botInfo.buildstring.releaseDate}`, color: config.colors.commands.secondary },
|
||||
{ text: `${botInfo.buildstring.codename}` },
|
||||
{ text: "11/22/22", color: config.colors.commands.primary },
|
||||
{ text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, color: config.colors.commands.secondary },
|
||||
]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
name: 'memusage',
|
||||
trustLevel: 0,
|
||||
aliases: [
|
||||
],
|
||||
description: 'check the bots and the servers ram usage',
|
||||
usages: [
|
||||
"on/enable/true",
|
||||
"off/disable/false",
|
||||
],
|
||||
},
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const args = context.arguments;
|
||||
switch (args[0]?.toLowerCase()) {
|
||||
case "on":
|
||||
case "enable":
|
||||
case "true":
|
||||
bot.memUsage.enabled = true;
|
||||
bot.chat.message('enabled memusage');
|
||||
break;
|
||||
case "off":
|
||||
case "enable":
|
||||
case "false":
|
||||
bot.memUsage.enabled = false;
|
||||
bot.chat.message('disabled memusage');
|
||||
break;
|
||||
throw new CommandError({ translate: "command.unknown.argument", color: "dark_red" });
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -12,13 +12,16 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
bot.core.refill()
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
bot.core.move();
|
||||
bot.tellraw("@a", "Refilling core,...")
|
||||
},
|
||||
|
||||
discordExecute (context) {
|
||||
const bot = context.bot;
|
||||
bot.core.refill();
|
||||
const config = context.config;
|
||||
bot.core.move();
|
||||
bot.tellraw("@a", "Refilling core,...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ module.exports = {
|
||||
],
|
||||
description: 'check the weather of cities',
|
||||
usages: [
|
||||
"<message>"
|
||||
"<city/zipcode>"
|
||||
],
|
||||
},
|
||||
async execute (context) {
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
const source = context.source;
|
||||
try {
|
||||
let component = [];
|
||||
const weather = await request(`https://api.weatherapi.com/v1/current.json?key=${config.weatherApiKey}&q=${args.join(' ')}`);
|
||||
const weather = await request(`https://api.weatherapi.com/v1/current.json?key=${config.weatherApiKey}&q=${args.join(' ')?.replaceAll(' ', ',')}`);
|
||||
const info = await weather.body.json();
|
||||
component.push({
|
||||
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s%s (%s%s)\n%s: %s %s %s (%s %s %s)\n%s: %s\n%s: %s",
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
const wiki = require('wikipedia')
|
||||
const CommandError = require('../../util/command_error')
|
||||
const { EmbedBuilder } = require('discord.js')
|
||||
const wiki = require('wikipedia');
|
||||
const CommandError = require('../../util/command_error');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
data: {
|
||||
name: 'wiki',
|
||||
@@ -14,19 +14,19 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
async execute (context) {
|
||||
const source = context.source
|
||||
const args = context.arguments
|
||||
const bot = context.bot
|
||||
const source = context.source;
|
||||
const args = context.arguments;
|
||||
const bot = context.bot;
|
||||
try {
|
||||
const page = await wiki.page(args.join(' '))
|
||||
const summary = await page.intro();
|
||||
bot.tellraw(`@a`, { text: `${summary}`, color: 'gray' });
|
||||
} catch (error) {
|
||||
if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
|
||||
bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' })
|
||||
} else {
|
||||
bot.tellraw(`@a`, `${error.toString()}`)
|
||||
}
|
||||
if (error.toString() === "pageError: TypeError: Cannot read properties of undefined (reading 'pages')") {
|
||||
bot.tellraw(`@a`, { text: 'Article not found!', color: 'dark_red' })
|
||||
} else {
|
||||
bot.tellraw(`@a`, `${error.toString()}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ module.exports = {
|
||||
if (roles?.some(role => role.name === `${config.discord.roles.trusted}`)) {
|
||||
bot.discord.message.reply('Valid trusted user')
|
||||
bot.chat.message(`Valid trusted user [${bot.discord.message.member.user.username}]`)
|
||||
} else if (roles?.some(role => role.name === `${config.discord.roles.owner}`)) {
|
||||
} else if (roles?.some(role => role.name === `${config.discord.roles.owner}` || role.name === `${config.discord.roles.fullAccess}`)) {
|
||||
bot.discord.message.reply('Valid Owner user')
|
||||
bot.chat.message(`Valid Owner User [${bot.discord.message.member.user.username}]`);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
prefixes:
|
||||
- "!"
|
||||
|
||||
discord:
|
||||
token: "discord token here"
|
||||
prefix: "!"
|
||||
invite: "discord invite here"
|
||||
enabled: true
|
||||
enabled: false
|
||||
roles:
|
||||
trusted: "trusted"
|
||||
admin: "admin"
|
||||
fullAccess: "full access"
|
||||
owner: "FNFBoyfriendBot Owner"
|
||||
|
||||
core:
|
||||
# core refill methods:
|
||||
# chat: refill core in chat
|
||||
# item refill core in a command block placed by the bot
|
||||
name: {"translate":"outOfMemory.message"}
|
||||
method: 'item'
|
||||
name: { text: "FNFBoyfriendBot Core", color: "#00FFFF" }
|
||||
itemName: { text: "FNFBoyfriendBot core item", color: "#00FFFF" }
|
||||
itemRefill: true
|
||||
# refilling core via item is buggy rn i recommend setting itemRefill to false for now
|
||||
area:
|
||||
start:
|
||||
x: 0
|
||||
@@ -26,7 +27,36 @@ core:
|
||||
y: 0
|
||||
z: 15
|
||||
|
||||
team:
|
||||
name: "FNFBoyfriendBot"
|
||||
suffix: {
|
||||
color: "dark_gray",
|
||||
translate: " [ %s ]",
|
||||
with: [
|
||||
{ color: "dark_red", text: "https://sus.red" }
|
||||
]
|
||||
}
|
||||
# make sure if nothing is set as the suffix it is set as { text: "" } as the packet reads "" as { text: "" }
|
||||
prefix: {
|
||||
color: "dark_gray",
|
||||
translate: "[%s: %s] ",
|
||||
with: [
|
||||
{ color: "aqua", text: "Prefix" },
|
||||
{ color: "dark_aqua", text: "!" }
|
||||
]
|
||||
}
|
||||
displayName: {
|
||||
translate: "%s%s%s",
|
||||
with: [
|
||||
{ color: "dark_blue", text: "FNF" },
|
||||
{ color: "dark_aqua", text: "Boyfriend" },
|
||||
{ color: "blue", text: "Bot" }
|
||||
]
|
||||
}
|
||||
# color HAS to come first before any components or it will break! dont ask why, its because of how nmp parses it
|
||||
|
||||
commandSetMessage: false
|
||||
# ^^ this is for when commands are ran in core
|
||||
|
||||
keys:
|
||||
trusted: "trusted key here"
|
||||
@@ -47,7 +77,6 @@ colors:
|
||||
|
||||
console:
|
||||
prefix: "c."
|
||||
filelogger: false
|
||||
|
||||
bots:
|
||||
- host: "localhost"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
data: {
|
||||
name: '<command name>',
|
||||
trustLevel: 0, // trust levels: 0, 1, 2, 3, 4
|
||||
aliases: [
|
||||
""
|
||||
],
|
||||
description: '',
|
||||
usages: [
|
||||
""
|
||||
],
|
||||
},
|
||||
execute (context) {
|
||||
|
||||
},
|
||||
discordExecute (context) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
export default {
|
||||
data: {
|
||||
name: '<command name>',
|
||||
trustLevel: 0, // trust levels: 0, 1, 2, 3, 4
|
||||
aliases: [
|
||||
|
||||
],
|
||||
description: '',
|
||||
usages: [
|
||||
""
|
||||
],
|
||||
},
|
||||
execute (context) {
|
||||
|
||||
},
|
||||
discordExecute (context) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
function whatevername (bot, options, config, discordClient) {
|
||||
|
||||
}
|
||||
module.exports = whatevername
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (bot, options, config, discordClient) => {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function () {
|
||||
|
||||
}
|
||||
+7
-3
@@ -9,21 +9,25 @@ const { Client, GatewayIntentBits } = require('discord.js');
|
||||
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits;
|
||||
const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
|
||||
console.log('Starting FNFBoyfriendBot');
|
||||
checks();
|
||||
process.stdout.write('\x1b]2;Starting FNFBoyfriendBot please wait,.....\x1b\x5c');
|
||||
|
||||
try {
|
||||
config = js_yaml.load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
if (config.core.method !== 'item' && config.core.method !== 'chat') {
|
||||
|
||||
checks(config);
|
||||
|
||||
/*if (config.core.method !== 'item' && config.core.method !== 'chat') {
|
||||
config.core.method = 'item';
|
||||
console.warn('invalid core method type defaulting to item');
|
||||
}
|
||||
}*/
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
})
|
||||
|
||||
if (config.discord.enabled) discordClient.login(config.discord.token);
|
||||
const bots = [];
|
||||
for (const options of config.bots) {
|
||||
|
||||
+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;
|
||||
|
||||
+102
-49
@@ -1,6 +1,10 @@
|
||||
const mcData = require('minecraft-data')('1.20.2');
|
||||
function core (bot, options, config) {
|
||||
let number = 0;
|
||||
const nbt = require('prismarine-nbt');
|
||||
|
||||
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 },
|
||||
@@ -9,9 +13,13 @@ function core (bot, options, config) {
|
||||
|
||||
position: null,
|
||||
|
||||
itemPosition: null,
|
||||
|
||||
currentBlockRelative: { x: 0, y: 0, z: 0 },
|
||||
|
||||
refill () {
|
||||
usePlacedCommandBlock: false,
|
||||
|
||||
chatRefill () {
|
||||
const pos = bot.core.position
|
||||
const { start, end } = bot.core.area
|
||||
|
||||
@@ -26,47 +34,64 @@ 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
|
||||
*/
|
||||
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)}'}`)
|
||||
} else if (config.core.method === 'item') {
|
||||
bot._client.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: {
|
||||
present: true,
|
||||
itemId: mcData.itemsByName.command_block.id,
|
||||
itemCount: 1,
|
||||
nbtData: {
|
||||
}
|
||||
}
|
||||
});
|
||||
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`
|
||||
bot.chat.command(`${command}`)
|
||||
},
|
||||
|
||||
bot._client.write('block_dig', {
|
||||
status: 0,
|
||||
location: {
|
||||
x: bot.position.x,
|
||||
y: bot.position.y,
|
||||
z: bot.position.z
|
||||
},
|
||||
face: 0
|
||||
});
|
||||
itemRefill () {
|
||||
const pos = bot.core.position;
|
||||
const { start, end } = bot.core.area;
|
||||
const itemPosition = bot.core.itemPosition;
|
||||
|
||||
bot._client.write('block_place', {
|
||||
hand: 0,
|
||||
location: {
|
||||
x: bot.position.x,
|
||||
y: bot.position.y,
|
||||
z: bot.position.z
|
||||
},
|
||||
direction: 0,
|
||||
cursorX: 0.1,
|
||||
cursorY: 0,
|
||||
cursorZ: 0.1,
|
||||
insideBlock: false
|
||||
});
|
||||
if (!pos) return;
|
||||
if (bot.options.useChat || bot.options.isCreayun || bot.options.isSavage) return;
|
||||
if (isNaN(pos.x + pos.x)) {
|
||||
bot.chat.command('spawn');
|
||||
return
|
||||
}
|
||||
/*^^^
|
||||
for checking is the core pos is null and if so
|
||||
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`
|
||||
|
||||
bot._client.write('set_creative_slot', {
|
||||
slot: 36,
|
||||
item: {
|
||||
present: true,
|
||||
itemId: mcData.itemsByName.repeating_command_block.id,
|
||||
itemCount: 1,
|
||||
nbtData: nbt.comp({
|
||||
BlockEntityTag: nbt.comp({
|
||||
CustomName: nbt.string(JSON.stringify(config.core.itemName))
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
bot._client.write('block_dig', {
|
||||
status: 0,
|
||||
location: itemPosition,
|
||||
face: 0
|
||||
});
|
||||
|
||||
bot._client.write('block_place', {
|
||||
hand: 0,
|
||||
location: itemPosition,
|
||||
direction: 0,
|
||||
cursorX: 0.1,
|
||||
cursorY: 0,
|
||||
cursorZ: 0.1,
|
||||
insideBlock: false
|
||||
});
|
||||
|
||||
if (bot.core.usePlacedCommandBlock) {
|
||||
return
|
||||
} else {
|
||||
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)}'}`,
|
||||
location: itemPosition,
|
||||
command,
|
||||
flags: 5,
|
||||
mode: 1
|
||||
})
|
||||
@@ -78,8 +103,19 @@ function core (bot, options, config) {
|
||||
x: Math.floor(pos.x / 16) * 16,
|
||||
y: 0,
|
||||
z: Math.floor(pos.z / 16) * 16
|
||||
};
|
||||
|
||||
bot.core.itemPosition = {
|
||||
x: pos.x,
|
||||
y: pos.y -1,
|
||||
z: pos.z
|
||||
}
|
||||
|
||||
if (config.core.itemRefill === true) {
|
||||
bot.core.itemRefill();
|
||||
} else {
|
||||
bot.core.chatRefill();
|
||||
}
|
||||
bot.core.refill()
|
||||
},
|
||||
|
||||
currentBlock () {
|
||||
@@ -113,15 +149,32 @@ function core (bot, options, config) {
|
||||
},
|
||||
|
||||
run (command) {
|
||||
const eee = Math.floor(Math.random() * 10000)
|
||||
const location = bot.core.currentBlock()
|
||||
if (!location) return
|
||||
const location = bot.core.currentBlock();
|
||||
const itemPosition = bot.core.itemPosition;
|
||||
|
||||
if (!location) return;
|
||||
if (bot.options.isSavage || bot.options.isCreayun || bot.options.useChat) {
|
||||
return
|
||||
} else {
|
||||
bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 });
|
||||
bot._client.write('query_block_nbt', ({ location: location, transactionId: eee}));
|
||||
bot.core.incrementCurrentBlock();
|
||||
if (bot.core.usePlacedCommandBlock) {
|
||||
bot._client.write('update_command_block', {
|
||||
command: command.substring(0, 32767),
|
||||
location: itemPosition,
|
||||
mode: 1,
|
||||
flags: 5,
|
||||
});
|
||||
|
||||
bot.core.incrementCurrentBlock();
|
||||
} else {
|
||||
bot._client.write('update_command_block', {
|
||||
command: command.substring(0, 32767),
|
||||
location,
|
||||
mode: 1,
|
||||
flags: 5
|
||||
});
|
||||
|
||||
bot.core.incrementCurrentBlock();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -134,11 +187,11 @@ function core (bot, options, config) {
|
||||
bot.on('packet.block_change', (data) => {
|
||||
// console.log('data pos ' + JSON.stringify(data.location))
|
||||
// console.log('core pos ' +JSON.stringify(bot.core.position));
|
||||
if (data.type === 0) {
|
||||
// if (data.type === 0) {
|
||||
// console.log('data pos ' + JSON.stringify(data.location));
|
||||
// console.log('core position ' + JSON.stringify(bot.core.position));
|
||||
// bot.core.refill();
|
||||
}
|
||||
//}
|
||||
})
|
||||
}
|
||||
module.exports = core;
|
||||
|
||||
@@ -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.fullAccess}` || 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.fullAccess}` ||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}` || role.name === `${config.discord.roles.fullAccess}`)
|
||||
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: [
|
||||
|
||||
+7
-33
@@ -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,
|
||||
@@ -89,7 +93,7 @@ function Console (bot, options, config) {
|
||||
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++
|
||||
})
|
||||
// console.log(ratelimit)
|
||||
|
||||
bot.on('bossBar', (message) => {
|
||||
if (!options.logging) return;
|
||||
if (ratelimit > 10) return;
|
||||
@@ -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
|
||||
@@ -39,7 +42,7 @@ function discord(bot, options, config, discordClient) {
|
||||
try {
|
||||
bot?.discord?.channel?.send(`\`\`\`ansi\n${discordQueue.join('\n').substring(0, 1984)}\n\`\`\``)
|
||||
} catch (error) {
|
||||
bot.console.warn(error.toString())
|
||||
console.error(error.toString())
|
||||
}
|
||||
discordQueue = []
|
||||
}, 2000)
|
||||
@@ -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) => {
|
||||
@@ -15,19 +18,20 @@ function player_list (bot, options, config) {
|
||||
action(entry)
|
||||
}
|
||||
}
|
||||
|
||||
bot.emit("player_info", packet);
|
||||
})
|
||||
|
||||
bot.on('packet.player_remove', async ({players}) => { // players has uuids of the players
|
||||
let player_completion = (await bot.tab_complete('scoreboard players add ')).filter(_ => _.tooltip == undefined) // exclude @a, @r, @s, @e, @p -aaa
|
||||
bot.players.forEach(async player => {
|
||||
if(!players.includes(player.uuid)) return
|
||||
if (!players.includes(player.uuid)) return
|
||||
|
||||
const a = player_completion.filter(_ => _.match == player.profile.name)
|
||||
if(a.length >= 1) {
|
||||
player.vanished = true
|
||||
if (a.length >= 1) {
|
||||
player.vanished = true;
|
||||
} else {
|
||||
bot.players = bot.players.filter(_ => _.uuid != player.uuid)
|
||||
bot.players = bot.players.filter(_ => _.uuid != player.uuid);
|
||||
bot.emit("player_left", player);
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -44,6 +48,11 @@ function player_list (bot, options, config) {
|
||||
displayName: undefined,
|
||||
vanished: false
|
||||
})
|
||||
if (entry.vanished) {
|
||||
bot.emit("player_vanished", entry);
|
||||
} else {
|
||||
bot.emit("player_joined", entry);
|
||||
}
|
||||
}
|
||||
|
||||
function initializeChat (entry) {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
function position (bot, options, config) {
|
||||
bot.position = null
|
||||
function position (context) {
|
||||
const bot = context.bot;
|
||||
bot.position = null;
|
||||
|
||||
bot.on('packet.position', packet => {
|
||||
bot.position = {
|
||||
x: packet.flags & 1 ? (this.x + packet.x) : packet.x,
|
||||
y: packet.flags & 2 ? (this.y + packet.y) : packet.y,
|
||||
z: packet.flags & 4 ? (this.z + packet.z) : packet.z
|
||||
}
|
||||
};
|
||||
|
||||
bot._client.write('teleport_confirm', { teleportId: packet.teleportId })
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+43
-26
@@ -1,4 +1,9 @@
|
||||
function selfcare (bot, options, config) {
|
||||
const sleep = require('../util/sleep');
|
||||
|
||||
function selfcare (context) {
|
||||
const bot = context.bot;
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
let entityId;
|
||||
let permissionLevel = 2;
|
||||
let unmuted = false;
|
||||
@@ -14,8 +19,6 @@ function selfcare (bot, options, config) {
|
||||
let register = false;
|
||||
let positionCount = 0;
|
||||
bot.vanished = true
|
||||
// You now have the tag: &8[&bPrefix&8: &3~&8]
|
||||
// You no longer have a tag
|
||||
bot.on('systemChat', (message) => {
|
||||
const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
|
||||
if (options.isSavage) {
|
||||
@@ -29,17 +32,8 @@ function selfcare (bot, options, config) {
|
||||
|
||||
else if (stringMessage === "You're already logged in!") register = false;
|
||||
else if (stringMessage === "Successful login!") register = false;
|
||||
/*
|
||||
You're already logged in!
|
||||
Please, register to the server with the command: /register <password> <ConfirmPassword>
|
||||
Please, login with the command: /login <password>
|
||||
Successfully registered!
|
||||
Successful login!
|
||||
You already have registered this username!
|
||||
*/
|
||||
|
||||
} else if (options.isKaboom) {
|
||||
// const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
|
||||
if (stringMessage === "Successfully enabled CommandSpy") commandSpy = true;
|
||||
else if (stringMessage === "Successfully enabled CommandSpy.") commandSpy = true;
|
||||
else if (stringMessage === "Successfully disabled CommandSpy") commandSpy = false;
|
||||
@@ -62,7 +56,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;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -93,31 +87,54 @@ You already have registered this username!
|
||||
}
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
bot.on("packet.teams", (data) => {
|
||||
/*
|
||||
bot.on("packet.teams", async (data) => {
|
||||
if (options.isSavage || options.isCreayun) return;
|
||||
try {
|
||||
/*
|
||||
if (data.team !== "FNFBoyfriendBot") {
|
||||
bot.chat.command(`minecraft:team add FNFBoyfriendBot`);
|
||||
// console.log(data);
|
||||
// bot.chat.command('minecraft:team add FNFBoyfriendBot');
|
||||
// if (data.team === "FNFBoyfriendBot") return;
|
||||
if (data.team === "FNFBoyfriendBot" && data.mode === 1) {
|
||||
bot.core.run("minecraft:team add FNFBoyfriendBot");
|
||||
}
|
||||
if (data.mode > 1 && !data.team === "FNFBoyfriendBot") {
|
||||
bot.chat.command(`minecraft:team add FNFBoyfriendBot`);
|
||||
|
||||
for (const eachPlayer of data?.players) {
|
||||
if (eachPlayer !== bot.options.username) {
|
||||
bot.core.run("minecraft:team empty FNFBoyfriendBot");
|
||||
await sleep(100);
|
||||
bot.core.run("minecraft:team join FNFBoyfriendBot");
|
||||
}
|
||||
}
|
||||
if (data.team === "FNFBoyfriendBot") {
|
||||
console.log(data);
|
||||
}
|
||||
*/
|
||||
} catch (e) {
|
||||
console.log(e.stack)
|
||||
}
|
||||
})
|
||||
})*/
|
||||
/*
|
||||
{
|
||||
team: 'FNFBoyfriendBot',
|
||||
mode: 3,
|
||||
name: undefined,
|
||||
friendlyFire: undefined,
|
||||
nameTagVisibility: undefined,
|
||||
collisionRule: undefined,
|
||||
formatting: undefined,
|
||||
prefix: undefined,
|
||||
suffix: undefined,
|
||||
players: [ 'Parker2991' ]
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
let timer;
|
||||
bot.on('packet.login', (packet) => {
|
||||
bot.on('packet.login', async (packet) => {
|
||||
entityId = packet.entityId;
|
||||
gameMode = packet.gameMode;
|
||||
clientLock = packet.gameMode;
|
||||
/* if (bot.options.isKaboom) {
|
||||
bot.core.run('minecraft:team add FNFBoyfriendBot');
|
||||
await sleep(100);
|
||||
bot.core.run('minecraft:team join FNFBoyfriendBot');
|
||||
}*/
|
||||
timer = setInterval(() => {
|
||||
if (bot.options.isSavage && !bot.options.isKaboom && !bot.options.isCreayun) {
|
||||
if (login) bot.chat.command('login amogusissus');
|
||||
|
||||
+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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
const sleep = require('../util/sleep');
|
||||
|
||||
module.exports = (context) => {
|
||||
const bot = context.bot;
|
||||
const options = context.options;
|
||||
const config = context.config;
|
||||
|
||||
bot.on("packet.login", async () => {
|
||||
if (options.isKaboom) {
|
||||
await sleep(100);
|
||||
bot.chat.command(`minecraft:team add ${config.team.name}`);
|
||||
await sleep(100);
|
||||
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
|
||||
}
|
||||
})
|
||||
|
||||
bot.on("packet.teams", async (data) => {
|
||||
if (options.isSavage || options.isCreayun) return;
|
||||
try {
|
||||
if (data.team === config.team.name) {
|
||||
// console.log(data);
|
||||
data?.players?.map(async (player) => {
|
||||
if (player !== bot.options.username) {
|
||||
await sleep(100);
|
||||
bot.core.run(`minecraft:team empty ${config.team.name}`);
|
||||
await sleep(100);
|
||||
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
|
||||
// this removes players who are not the bot
|
||||
}
|
||||
});
|
||||
|
||||
if (data.mode == 1) {
|
||||
// this is checking if the team has been deleted
|
||||
bot.core.run(`minecraft:team add ${config.team.name}`);
|
||||
await sleep(100);
|
||||
bot.core.run(`minecraft:team join ${config.team.name} @a[name="${bot.options.username}"]`);
|
||||
} if (data.name !== JSON.stringify(config.team.displayName)) {
|
||||
// this checks if the team displayName matches the one set in the config
|
||||
bot.core.run(`minecraft:team modify ${config.team.name} displayName ${JSON.stringify(config.team.displayName)}`);
|
||||
} if (data.prefix !== JSON.stringify(config.team.prefix)) {
|
||||
// this checks if the team prefix matches the one set in the config
|
||||
bot.core.run(`minecraft:team modify ${config.team.name} prefix ${JSON.stringify(config.team.prefix)}`);
|
||||
} if (data.suffix !== JSON.stringify(config.team.suffix)) {
|
||||
// this checks if the team suffix matches the one set in the config
|
||||
bot.core.run(`minecraft:team modify ${config.team.name} suffix ${JSON.stringify(config.team.suffix)}`)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.stack)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -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),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const ChatMessage = require('prismarine-chat')('1.20.2');
|
||||
const util = require('util');
|
||||
function creayun (messageobj, data) {
|
||||
try {
|
||||
let match;
|
||||
let sender;
|
||||
const stringify = message => new ChatMessage(message).toString()
|
||||
@@ -21,5 +22,8 @@ function creayun (messageobj, data) {
|
||||
// console.log(sender)
|
||||
return { sender, contents: match[3], type: 'minecraft:chat'};
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.toString())
|
||||
}
|
||||
}
|
||||
module.exports = creayun;
|
||||
|
||||
@@ -14,10 +14,10 @@ function VanillaChat (message, data, context) {
|
||||
const stringUsername = data.getMessageAsPrismarine(senderComponent).toString() // TypeError: data.getMessageAsPrismarine is not a function
|
||||
sender = data.players.find(player => player.profile.name === stringUsername)
|
||||
}
|
||||
if (!sender) return stringUsername
|
||||
if (!sender) return //stringUsername
|
||||
return { sender, contents, type: 'minecraft:chat', senderComponent }
|
||||
} catch(e) {
|
||||
console.error(`${e.toString()}`)
|
||||
console.error(`${e.stack}`)
|
||||
}
|
||||
}
|
||||
module.exports = VanillaChat;
|
||||
|
||||
@@ -15,55 +15,6 @@ function ansi (message) {
|
||||
'\x1B[4m': "\x1B[24m", // underline
|
||||
'\x1B[9m': "\x1B[29m", // strike through
|
||||
'\x1B[6m': "\x1B[29m" // obfuscated
|
||||
|
||||
/*
|
||||
Black 30 40
|
||||
Red 31 41
|
||||
Green 32 42
|
||||
Yellow 33 43
|
||||
Blue 34 44
|
||||
Magenta 35 45
|
||||
Cyan 36 46
|
||||
White 37 47
|
||||
Default 39 49
|
||||
Reset 0 0
|
||||
ESC[1;34;{...}m Set graphics modes for cell, separated by semicolon (;).
|
||||
ESC[0m reset all modes (styles and colors)
|
||||
ESC[1m ESC[22m set bold mode.
|
||||
ESC[2m ESC[22m set dim/faint mode.
|
||||
ESC[3m ESC[23m set italic mode.
|
||||
ESC[4m ESC[24m set underline mode.
|
||||
ESC[5m ESC[25m set blinking mode
|
||||
ESC[7m ESC[27m set inverse/reverse mode
|
||||
ESC[8m ESC[28m set hidden/invisible mode
|
||||
ESC[9m ESC[29m set strikethrough mode.
|
||||
*/
|
||||
/*
|
||||
const defaultAnsiCodes = {
|
||||
'§0': '\u001b[30m',
|
||||
'§1': '\u001b[34m',
|
||||
'§2': '\u001b[32m',
|
||||
'§3': '\u001b[36m',
|
||||
'§4': '\u001b[31m',
|
||||
'§5': '\u001b[35m',
|
||||
'§6': '\u001b[33m',
|
||||
'§7': '\u001b[37m',
|
||||
'§8': '\u001b[90m',
|
||||
'§9': '\u001b[94m',
|
||||
'§a': '\u001b[92m',
|
||||
'§b': '\u001b[96m',
|
||||
'§c': '\u001b[91m',
|
||||
'§d': '\u001b[95m',
|
||||
'§e': '\u001b[93m',
|
||||
'§f': '\u001b[97m',
|
||||
'§l': '\u001b[1m',
|
||||
'§o': '\u001b[3m',
|
||||
'§n': '\u001b[4m',
|
||||
'§m': '\u001b[9m',
|
||||
'§k': '\u001b[6m',
|
||||
'§r': '\u001b[0m'
|
||||
}
|
||||
*/
|
||||
};
|
||||
let i = message;
|
||||
|
||||
|
||||
+8
-27
@@ -1,38 +1,19 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
async function loadModules (bot, options, config, discordClient) {
|
||||
// let module
|
||||
bot.loadModule = module => module(bot, options, config, discordClient)
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../', 'modules'))) {
|
||||
try {
|
||||
if (filename.endsWith(".mjs")) {
|
||||
// const module = await import(path.join(__dirname, '../', 'modules', filename));
|
||||
// bot.loadModule(module);
|
||||
} else if (filename.endsWith(".js")) {
|
||||
const module = require(path.join(__dirname, '../', 'modules', filename));
|
||||
bot.loadModule(module);
|
||||
if (filename.endsWith(".js")) {
|
||||
const module = require(path.join(__dirname, '../modules', filename));
|
||||
module({ bot, options, config, discordClient });
|
||||
} if (filename.endsWith(".mjs")) {
|
||||
const module = await import(path.join(__dirname, '../modules', filename));
|
||||
module.default(bot, options, config, discordClient);
|
||||
}
|
||||
//bot.loadModule(module)
|
||||
} catch (error) {
|
||||
console.error('Failed to load module', filename, ':', error)
|
||||
console.error(`Failed to load module ${filename} due to error`);
|
||||
console.error(`\x1b[31m${error.stack}\x1b[0m`);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = loadModules;
|
||||
/*
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
||||
try {
|
||||
if (filename.endsWith('.mjs')) {
|
||||
let commands = await import(path.join(__dirname, '../commands', filename))
|
||||
bot.commandManager.register(commands.command);
|
||||
bot.commandManager.commandlist.push(commands.command);
|
||||
} if (filename.endsWith('.js')) {
|
||||
let commands = require(path.join(__dirname, '../commands', filename));
|
||||
bot.commandManager.register(commands);
|
||||
bot.commandManager.commandlist.push(commands);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load command', filename, ':', error)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user