forked from afspiegeling/NitoriBot
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0aed4d7d7a | ||
|
|
831fda8607 |
+2
-1
@@ -6,4 +6,5 @@ logs/*
|
||||
src/data/filter.json
|
||||
data/filter.json
|
||||
prototyping-crap
|
||||
|
||||
src/data/trustedPlayers.js
|
||||
data/trustedPlayers.js
|
||||
|
||||
Generated
+531
-2671
File diff suppressed because it is too large
Load Diff
+4
-2
@@ -1,21 +1,23 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1",
|
||||
"cowsay": "^1.6.0",
|
||||
"cowsay2": "^2.0.4",
|
||||
"discord.js": "^14.11.0",
|
||||
"discord.js": "^14.16.3",
|
||||
"java-parser": "^2.3.2",
|
||||
"js-yaml": "^4.1.0",
|
||||
"json-stringify": "^1.0.0",
|
||||
"json5": "^2.2.3",
|
||||
"jvm": "^0.5.3",
|
||||
"man-db": "^1.0.3",
|
||||
"minecraft-data": "^3.36.1",
|
||||
"minecraft-data": "^3.69.0",
|
||||
"minecraft-protocol": "^1.47.0",
|
||||
"mojangson": "^2.0.4",
|
||||
"node-gyp": "^10.2.0",
|
||||
"prismarine-auth": "^2.2.0",
|
||||
"prismarine-chat": "^1.10.1",
|
||||
"prismarine-registry": "^1.7.0",
|
||||
"proxy-agent": "^6.4.0",
|
||||
"wikipedia": "^2.1.2",
|
||||
"xml2js": "^0.6.2"
|
||||
}
|
||||
|
||||
+18
-22
@@ -1,8 +1,9 @@
|
||||
const mc = require('minecraft-protocol')
|
||||
const { EventEmitter } = require('events')
|
||||
//require("events").EventEmitter.defaultMaxListeners = Infinity;
|
||||
EventEmitter.defaultMaxListeners = Infinity
|
||||
const mc = require('minecraft-protocol');
|
||||
const { EventEmitter } = require('events');
|
||||
EventEmitter.defaultMaxListeners = Infinity;
|
||||
const util = require('util');
|
||||
const createRegistry = require('prismarine-registry');
|
||||
const ChatMessage = require('prismarine-chat');
|
||||
function createBot(options = {}, config) {
|
||||
const bot = new EventEmitter();
|
||||
bot.options = {
|
||||
@@ -12,7 +13,6 @@ function createBot(options = {}, config) {
|
||||
hideErrors: options.hideErrors ??= true, // HACK: Hide errors by default as a lazy fix to console being spammed with them
|
||||
};
|
||||
bot.options = options;
|
||||
const ChatMessage = require('prismarine-chat')(bot.options.version);
|
||||
// Create our client object, put it on the bot, and register some events
|
||||
bot.on('init_client', client => {
|
||||
client.on('packet', (data, meta) => {
|
||||
@@ -23,25 +23,24 @@ function createBot(options = {}, config) {
|
||||
client.on('login', () => {
|
||||
bot.uuid = client.uuid
|
||||
bot.username = client.username
|
||||
bot.registry = createRegistry(client.version)
|
||||
bot.registry.language = require('./data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
})
|
||||
client.on('disconnect', (data) => {
|
||||
bot.emit("disconnect", data)
|
||||
// bot.console.info(JSON.stringify(data))
|
||||
// bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||
if (config.console.filelogger) {
|
||||
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
|
||||
}
|
||||
client.on('disconnect', data => {
|
||||
bot.emit("disconnect", data);
|
||||
console.log(ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi())
|
||||
bot.console.warn(`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`)
|
||||
})
|
||||
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())
|
||||
})
|
||||
|
||||
client.on('error', error => {
|
||||
bot.console.warn(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
|
||||
// bot?.discord?.channel?.send(error.toString())
|
||||
if (config.console.filelogger) {
|
||||
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(error.toString()))
|
||||
}
|
||||
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 }) => {
|
||||
@@ -50,11 +49,8 @@ function createBot(options = {}, config) {
|
||||
|
||||
client.on('kick_disconnect', (data) => {
|
||||
bot.emit("kick_disconnect", data.reason)
|
||||
bot.console?.warn(ChatMessage.fromNotch(`§8[§bClient Reconnect§8]§r `)?.toAnsi() + util.inspect(data.reason))
|
||||
bot.console?.warn(`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`)
|
||||
bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||
if (config.console.filelogger) {
|
||||
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
|
||||
}
|
||||
})
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
@@ -62,7 +58,7 @@ function createBot(options = {}, config) {
|
||||
});
|
||||
})
|
||||
|
||||
const client = options.client ?? new mc.createClient(options)
|
||||
const client = options.client ?? new mc.createClient(bot.options)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
bot.bots = options.bots ?? [bot]
|
||||
|
||||
@@ -4,7 +4,13 @@ module.exports = {
|
||||
aliases: [
|
||||
|
||||
],
|
||||
usages: [],
|
||||
usages: [
|
||||
'server/srv <all/servername>',
|
||||
'customchat <on/true/enable/off/false/disable>',
|
||||
'say <message>',
|
||||
'validate/validation/val <owner/o/admin/a/trusted/t>',
|
||||
'logging/togglelogging/logtoconsole <on/true/enable/off/false/disable>'
|
||||
],
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
const args = context.arguments;
|
||||
@@ -68,7 +74,7 @@ module.exports = {
|
||||
if (bot.console.customChat.enabled) {
|
||||
bot.console.customChat.chat(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`)
|
||||
} else if (!bot.console.customChat.enabled) {
|
||||
// bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`)
|
||||
bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`)
|
||||
}
|
||||
break
|
||||
case "trusted":
|
||||
@@ -85,6 +91,7 @@ module.exports = {
|
||||
break
|
||||
case 'logging':
|
||||
case 'togglelogging':
|
||||
case 'logtoconsole':
|
||||
switch (args[1]?.toLowerCase()) {
|
||||
case 'on':
|
||||
case 'enable':
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
const CommandError = require('../util/command_error');
|
||||
module.exports = {
|
||||
name: 'filter',
|
||||
trustLevel: 1,
|
||||
trustLevel: 2,
|
||||
aliases: [
|
||||
"blacklist"
|
||||
],
|
||||
description: '',
|
||||
description: 'filters players',
|
||||
usages: [
|
||||
"list",
|
||||
"--regex(-r) --ignorecase(-i) add <player>",
|
||||
@@ -89,7 +90,12 @@ module.exports = {
|
||||
break;
|
||||
case "--ignorecase":
|
||||
case "-i":
|
||||
bot.filter.add(true, false, args.slice(2).join(' '))
|
||||
switch (args[2]?.toLowerCase()) {
|
||||
case "add":
|
||||
bot.filter.add(true, false, args[3]);
|
||||
bot.chat.message(`Added ${args[3]} to the filter`)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "add":
|
||||
case "a":
|
||||
|
||||
+10
-8
@@ -54,7 +54,7 @@ module.exports = {
|
||||
with: [
|
||||
{ text: `${config.prefixes[0]}`, color: "dark_blue" },
|
||||
{ text: `${command.name} <trusted/admin/owner hashes>`, color: "blue" },
|
||||
{ text: `${command.usages}`, color: "aqua" },
|
||||
{ text: `${usages}`, color: "aqua" },
|
||||
]
|
||||
})
|
||||
} else if (command?.trustLevel === 2) {
|
||||
@@ -63,7 +63,7 @@ module.exports = {
|
||||
with: [
|
||||
{ text: `${config.prefixes[0]}`, color: "dark_blue" },
|
||||
{ text: `${command.name} <admin/owner hashes>`, color: "blue" },
|
||||
{ text: `${command.usages}`, color: "aqua" },
|
||||
{ text: `${usages}`, color: "aqua" },
|
||||
]
|
||||
})
|
||||
} else if (command?.trustLevel === 3) {
|
||||
@@ -72,16 +72,16 @@ module.exports = {
|
||||
with: [
|
||||
{ text: `${config.prefixes[0]}`, color: "dark_blue" },
|
||||
{ text: `${command.name} <owner hash>`, color: "blue" },
|
||||
{ text: `${command.usages}`, color: "aqua" },
|
||||
{ text: `${usages}`, color: "aqua" },
|
||||
]
|
||||
})
|
||||
} else {
|
||||
} else if (command?.trustLevel === 0 || command.trustLevel === 4) {
|
||||
usagesComponent.push({
|
||||
translate: "%s%s %s",
|
||||
with: [
|
||||
{ text: `${config.prefixes[0]}`, color: "dark_blue" },
|
||||
{ text: `${command.name}`, color: "blue" },
|
||||
{ text: `${command.usages.toString().replaceAll(',','')}`, color: "aqua" },
|
||||
{ text: `${usages.toString().replaceAll(',','')}`, color: "aqua" },
|
||||
]
|
||||
})
|
||||
}
|
||||
@@ -110,7 +110,7 @@ module.exports = {
|
||||
})
|
||||
commandComponent.push("\n");
|
||||
commandComponent.push(usagesComponent);
|
||||
for (const aliases of command.aliases) {
|
||||
// for (const aliases of command.aliases) {
|
||||
if (args[0]?.toLowerCase() === command.name) {
|
||||
if (bot.options.isSavage) {
|
||||
bot.chat.message(`${bot.getMessageAsPrismarine(commandComponent)?.toMotd().replaceAll('§','&')}`);
|
||||
@@ -118,7 +118,8 @@ module.exports = {
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, commandComponent)
|
||||
}
|
||||
return;
|
||||
} if (args[0]?.toLowerCase() === aliases) {
|
||||
}
|
||||
/* } if (args[0]?.toLowerCase() === aliases) {
|
||||
if (bot.options.isSavage) {
|
||||
bot.chat.message(`${bot.getMessageAsPrismarine(commandComponent)?.toMotd().replaceAll('§','&')}`)
|
||||
} else {
|
||||
@@ -126,7 +127,8 @@ module.exports = {
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
console.log(aliases)*/
|
||||
// }
|
||||
if (command.trustLevel === 0) {
|
||||
public.push([
|
||||
{
|
||||
|
||||
+18
-1
@@ -54,6 +54,15 @@ module.exports = {
|
||||
}
|
||||
break
|
||||
case 'config':
|
||||
if (bot.options.isKaboom) {
|
||||
mode = 'Kaboom'
|
||||
} else if (bot.options.isCreayun) {
|
||||
mode = 'Creayun'
|
||||
} else if (bot.options.useChat) {
|
||||
mode = 'useChat / Kaboom'
|
||||
} else if (bot.options.isSavage) {
|
||||
mode = 'Savage'
|
||||
}
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
|
||||
{
|
||||
text: `Minecraft username \u203a ${bot.options.username}\n`,
|
||||
@@ -104,6 +113,14 @@ module.exports = {
|
||||
color: 'gold'
|
||||
},
|
||||
{
|
||||
text: 'Mode \u203a ',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: `${mode}`,
|
||||
color: 'gray',
|
||||
}
|
||||
/* {
|
||||
text: `isKaboom \u203a ${bot.options.isKaboom}\n`,
|
||||
color: "gray",
|
||||
},
|
||||
@@ -114,7 +131,7 @@ module.exports = {
|
||||
{
|
||||
text: `isSavage \u203a ${bot.options.isSavage}`,
|
||||
color: "gray",
|
||||
},
|
||||
},*/
|
||||
]);
|
||||
break;
|
||||
case 'discord':
|
||||
|
||||
@@ -11,10 +11,10 @@ module.exports = {
|
||||
],
|
||||
execute (context) {
|
||||
const bot = context.bot;
|
||||
process.exit(69);
|
||||
process.kill(process.pid);
|
||||
},
|
||||
discordExecute (context) {
|
||||
const bot = context.bot;
|
||||
process.exit(69);
|
||||
process.kill(process.pid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ module.exports = {
|
||||
}
|
||||
component.pop()
|
||||
const ansi = bot.getMessageAsPrismarine([{ text: `Players: `, color:'gray' }, { text: '(' , color: 'gray' }, { text: `${JSON.stringify(bot.players.length)}`, color: 'gold' }, { text: ')\n', color: 'gray' }, component])?.toAnsi()
|
||||
const fix = fixansi(ansi.replaceAll('`', '`\u200b'))
|
||||
const fix = fixansi(ansi.replaceAll('`', '`\u200b').substring(0, 3080))
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(`${config.colors.discord.embed}`)
|
||||
.setTitle(`${this.name} Command`)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const CommandError = require('../util/command_error.js')
|
||||
module.exports = {
|
||||
name: 'netmsg',
|
||||
trustLevel: 0,
|
||||
trustLevel: 1,
|
||||
aliases: [
|
||||
|
||||
],
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
module.exports = {
|
||||
name: 'reload',
|
||||
trustLevel: 3,
|
||||
aliases: [
|
||||
],
|
||||
description: 'reloads commands',
|
||||
usages: [
|
||||
""
|
||||
],
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
bot.tellraw("@a", [
|
||||
{ text: "Reloading ", color: "gray" },
|
||||
{ text: '(', color: "gray" },
|
||||
{ text: `${bot.commandManager.commandlist.length}`, color: "gold" },
|
||||
{ text: ') ', color: "gray" },
|
||||
{ text: 'commands', color: "gray" },
|
||||
])
|
||||
for (const eachBot of bot.bots) {
|
||||
eachBot.commandManager.reload();
|
||||
}
|
||||
},
|
||||
discordExecute (context) {
|
||||
const bot = context.bot;
|
||||
bot.discord.message.reply("Reloading Commands,.........");
|
||||
for (const eachBot of bot.bots) {
|
||||
eachBot.commandManager.reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
const CommandError = require('../util/command_error');
|
||||
const { request } = require('undici');
|
||||
module.exports = {
|
||||
name: 'weather',
|
||||
trustLevel: 0,
|
||||
aliases: [
|
||||
],
|
||||
description: 'check the weather of cities',
|
||||
usages: [
|
||||
"<message>"
|
||||
],
|
||||
async execute (context) {
|
||||
const bot = context.bot
|
||||
const args = context.arguments;
|
||||
const config = context.config;
|
||||
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 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",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{ text: "Location", color: config.colors.commands.primary },
|
||||
{ text: `${info.location.name}, ${info.location.region}, ${info.location.country}`, color: config.colors.commands.secondary },
|
||||
{ text: "Latitude", color: config.colors.commands.primary },
|
||||
{ text: `${info.location.lat}`, color: config.colors.integer },
|
||||
{ text: "Longitude", color: config.colors.commands.primary },
|
||||
{ text: `${info.location.lon}`, color: config.colors.integer },
|
||||
{ text: "Time zone", color: config.colors.commands.primary },
|
||||
{ text: `${info.location.tz_id}`, color: config.colors.commands.secondary },
|
||||
{ text: "Time", color: config.colors.commands.primary },
|
||||
{ text: `${new Date().toLocaleTimeString("en-US", { timeZone: info.location.tz_id, })}`, color: config.colors.integer },
|
||||
{ text: "Temp", color: config.colors.commands.primary },
|
||||
{ text: `${info.current.temp_c}`, color: config.colors.integer },
|
||||
{ text: "\u00b0C", color: config.colors.commands.secondary },
|
||||
{ text: `${info.current.temp_f}`, color: config.colors.integer },
|
||||
{ text: "\u00b0F", color: config.colors.commands.secondary },
|
||||
{ text: "Wind speed" , color: config.colors.commands.primary },
|
||||
{ text: `${info.current.wind_kph}`, color: config.colors.integer },
|
||||
{ text: `kph`, color: config.colors.commands.secondary },
|
||||
{ text: `${info.current.wind_dir}`, color: config.colors.secondary },
|
||||
{ text: `${info.current.wind_mph}`, color: config.colors.integer },
|
||||
{ text: `mph`, color: config.colors.commands.secondary },
|
||||
{ text: `${info.current.wind_dir}`, color: config.colors.commands.secondary },
|
||||
{ text: "Condition", color: config.colors.commands.primary },
|
||||
{ text: `${info.current.condition.text}`, color: config.colors.commands.secondary },
|
||||
{ text: "Humidity", color: config.colors.commands.primary },
|
||||
{ text: `${info.current.humidity}`, color: config.colors.integer },
|
||||
]
|
||||
})
|
||||
bot.tellraw("@a", component)
|
||||
} catch (e) {
|
||||
if (e.toString() === "TypeError: Cannot read properties of undefined (reading 'name')" && args.length !== 0) {
|
||||
bot.chat.message('The location is invalid please try a valid location');
|
||||
} else if (args.length === 0) {
|
||||
bot.chat.message('there were no arguments detected')
|
||||
} else {
|
||||
bot.chat.message(`${e.toString()}`);
|
||||
console.warn(e.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
const { parseString } = require('xml2js');
|
||||
const CommandError = require('../util/command_error')
|
||||
const util = require('util');
|
||||
module.exports = {
|
||||
name: 'xml',
|
||||
trustLevel: 3,
|
||||
aliases: [
|
||||
],
|
||||
description: 'eval xml shit',
|
||||
usages: [
|
||||
"<xml code>"
|
||||
],
|
||||
execute (context) {
|
||||
const bot = context.bot;
|
||||
const args = context.arguments;
|
||||
parseString(args.slice(1).join(' '), function (err, result) {
|
||||
if (err) throw new CommandError(err.toString())
|
||||
bot.tellraw("@a", [
|
||||
{
|
||||
text: "Result \u203a \n",
|
||||
color: "gray"
|
||||
},
|
||||
{
|
||||
text: `${util.inspect(result)}`
|
||||
}
|
||||
])
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
prefixes:
|
||||
- "!"
|
||||
- "fnfbfbot!"
|
||||
|
||||
discord:
|
||||
token: "discord token here"
|
||||
@@ -23,17 +22,24 @@ core:
|
||||
y: 0
|
||||
z: 15
|
||||
|
||||
commandSetMessage: true
|
||||
commandSetMessage: false
|
||||
|
||||
keys:
|
||||
trusted: "trusted key here"
|
||||
admin: "admin key here"
|
||||
owner: "owner key here"
|
||||
|
||||
weatherApiKey: ""
|
||||
|
||||
colors:
|
||||
integer: "gold"
|
||||
discord:
|
||||
embed: "#000000"
|
||||
error: "#FF0000"
|
||||
commands:
|
||||
primary: "dark_blue"
|
||||
secondary: "blue"
|
||||
tertiary: "dark_gray"
|
||||
|
||||
console:
|
||||
prefix: "c."
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"bot": {
|
||||
"buildstring": {
|
||||
"version": "v6.0.5",
|
||||
"build":"1050",
|
||||
"version": "v6.0.7",
|
||||
"build":"1080",
|
||||
"codename":""
|
||||
},
|
||||
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
[{"player":"aaa"},{"player":"Parker2991"},{"player":"FNFBoyfriendBot"}]
|
||||
@@ -4,10 +4,13 @@ const loadModules = require('./util/loadModules');
|
||||
const js_yaml = require('js-yaml');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const checks = require('./util/checks');
|
||||
const { Client, GatewayIntentBits } = require('discord.js');
|
||||
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits;
|
||||
const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
|
||||
console.log('Starting FNFBoyfriendBot');
|
||||
checks();
|
||||
/*
|
||||
if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
|
||||
console.log("Config not found creating config from the default config");
|
||||
fs.copyFileSync(
|
||||
@@ -15,6 +18,7 @@ if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
|
||||
path.join(__dirname, "../config.yml")
|
||||
)
|
||||
}
|
||||
*/
|
||||
try {
|
||||
config = js_yaml.load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
|
||||
} catch (e) {
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ function chat (bot, options, config) {
|
||||
|
||||
bot.on('packet.system_chat', packet => {
|
||||
const message = tryParse(packet.content)
|
||||
if (config.commandSetMessage) {
|
||||
if (!config.commandSetMessage) {
|
||||
if (message.translate === 'advMode.setCommand.success') return // Ignores command set message
|
||||
}
|
||||
if (message.translate === 'multiplayer.message_not_delivered') return
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
const CommandSource = require('../util/command_source');
|
||||
module.exports = (bot, options, config) => {
|
||||
let ratelimit = 0;
|
||||
bot.on("parsed_message", (data) => {
|
||||
if (data.type !== "minecraft:chat") return;
|
||||
const prefixes = config.prefixes;
|
||||
prefixes.map((prefix) => {
|
||||
const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString();
|
||||
if (!plainMessage.startsWith(prefix)) return
|
||||
const command = plainMessage.substring(prefix.length)
|
||||
const source = new CommandSource(data.sender, { discord: false, console: false }, true)
|
||||
ratelimit++
|
||||
setTimeout(() => {
|
||||
ratelimit--
|
||||
}, 1000)
|
||||
if (ratelimit > 2) {
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
|
||||
} else if (command.split(" ")[0].length === 0) {
|
||||
} else {
|
||||
bot.commandManager.executeString(source, command)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -11,6 +11,7 @@ function command_loop (bot, options, config) {
|
||||
})
|
||||
|
||||
bot.on('packet.login', () => {
|
||||
if (this.list.length === 0) return
|
||||
timer = ({ timer: setInterval(() => bot.core.run(command), interval), command, interval })
|
||||
this.list.push(timer);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require('path');
|
||||
const CommandError = require('../util/command_error.js');
|
||||
const CommandSource = require('../util/command_source');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
function command_manager (bot, options, config, discordClient) {
|
||||
async function command_manager (bot, options, config, discordClient) {
|
||||
bot.commandManager = {
|
||||
commands: {},
|
||||
commandlist: [],
|
||||
@@ -20,20 +20,16 @@ function command_manager (bot, options, config, discordClient) {
|
||||
}
|
||||
} else if (!source?.sources?.discord && !source?.sources?.console) {
|
||||
if (!command || !command.execute)
|
||||
throw new CommandError([
|
||||
{
|
||||
translate: `command.unknown.command`
|
||||
},
|
||||
{
|
||||
text: '\n'
|
||||
},
|
||||
{
|
||||
text: `${commandName} `
|
||||
},
|
||||
{
|
||||
translate: "command.context.here"
|
||||
}
|
||||
])
|
||||
throw new CommandError({
|
||||
translate: "%s%s%s %s",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ translate: "command.unknown.command", color: "red" },
|
||||
{ text: "\n" },
|
||||
{ text: `${commandName}` },
|
||||
{ translate: "command.context.here", color: "red" }
|
||||
]
|
||||
})
|
||||
} else if (source?.sources?.console && !source?.sources?.discord) {
|
||||
if (!command || !command.execute)
|
||||
bot.console.warn([
|
||||
@@ -58,25 +54,24 @@ function command_manager (bot, options, config, discordClient) {
|
||||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
if (command?.trustLevel === 1 && !source?.sources?.discord) {
|
||||
// const hash = args[0]
|
||||
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash" })
|
||||
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 or admin or owner hash', color: 'dark_red' })
|
||||
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an 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 or admin or owner hash', color: 'dark_red' });
|
||||
} else if (command?.trustLevel === 1 && source?.sources.discord) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!' })
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
|
||||
}
|
||||
if (command?.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" })
|
||||
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' })
|
||||
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.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' });
|
||||
}
|
||||
if (command?.trustLevel === 3 && !source.sources.discord && !source.sources.console) {
|
||||
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash" })
|
||||
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?.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!' })
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" })
|
||||
} else if (command?.trustLevel === 4 && !source.sources.console) {
|
||||
throw new CommandError('This command can only be ran via console');
|
||||
throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" });
|
||||
}
|
||||
}
|
||||
if (!command?.discordExecute && command && source?.sources?.discord) {
|
||||
@@ -86,7 +81,7 @@ function command_manager (bot, options, config, discordClient) {
|
||||
} else if (!command?.execute && command && !source?.sources?.discord) {
|
||||
throw new CommandError(`${command.name} command is not supported in game!`)
|
||||
} else if (command?.execute && command && !source?.sources?.discord) {
|
||||
return command?.execute({ bot, source, arguments: args, config, discordClient})
|
||||
return command?.execute({ bot, source, arguments: args, config, discordClient });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error.stack)
|
||||
@@ -105,7 +100,7 @@ function command_manager (bot, options, config, discordClient) {
|
||||
if (bot.options.isSavage || bot.options.isCreayun) {
|
||||
bot.chat.message(`&4${error.message}`)
|
||||
} else {
|
||||
bot.tellraw("@a", { text: error.message, color: "dark_red" })
|
||||
bot.tellraw("@a", error._message)
|
||||
}
|
||||
} else {
|
||||
if (bot.options.isSavage || bot.options.isCreayun) {
|
||||
@@ -114,11 +109,10 @@ function command_manager (bot, options, config, discordClient) {
|
||||
bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
|
||||
}
|
||||
}
|
||||
// else bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
|
||||
//}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
executeString (source, command) {
|
||||
const [commandName, ...args] = command.split(' ')
|
||||
return this.execute(source, commandName, args)
|
||||
@@ -137,9 +131,11 @@ function command_manager (bot, options, config, discordClient) {
|
||||
command.aliases.map((a) => (this.commands[a] = command));
|
||||
}
|
||||
},
|
||||
|
||||
unregister (command) {
|
||||
this.commands = {};
|
||||
},
|
||||
|
||||
getCommand (name) {
|
||||
return this.commands[name]
|
||||
},
|
||||
@@ -147,54 +143,23 @@ function command_manager (bot, options, config, discordClient) {
|
||||
getCommands () {
|
||||
return Object.values(this.commands)
|
||||
},
|
||||
|
||||
reload() {
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, "../commands"))) {
|
||||
try {
|
||||
delete require.cache[require.resolve(path.join(__dirname, "../commands/", filename))]
|
||||
const command = require(path.join(__dirname, "../commands/", filename));
|
||||
bot.commandManager.register(command);
|
||||
bot.commandManager.commandlist.pop(command)
|
||||
bot.commandManager.commandlist.push(command)
|
||||
} catch (error) {
|
||||
bot.tellraw("@a", { text: `Failed to reload file ${filename}\n${error.stack}`, color: "red" })
|
||||
bot?.console?.fileLogger(error.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commandlist = [];
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
||||
try {
|
||||
const command = require(path.join(__dirname, '../commands', filename))
|
||||
bot.commandManager.register(command)
|
||||
bot.commandManager.commandlist.push(command)
|
||||
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)
|
||||
bot?.console.filelogging(error.stack)
|
||||
console.error('Failed to load command ', filename, ':', error)
|
||||
}
|
||||
}
|
||||
let ratelimit = 0;
|
||||
bot.on("parsed_message", (data) => {
|
||||
if (data.type !== "minecraft:chat") return;
|
||||
const prefixes = config.prefixes;
|
||||
prefixes.map((prefix) => {
|
||||
const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString();
|
||||
if (!plainMessage.startsWith(prefix)) return
|
||||
const command = plainMessage.substring(prefix.length)
|
||||
const source = new CommandSource(data.sender, { discord: false, console: false }, true)
|
||||
ratelimit++
|
||||
setTimeout(() => {
|
||||
ratelimit--
|
||||
}, 1000)
|
||||
if (ratelimit > 2) {
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
|
||||
} else if (command.split(" ")[0].length === 0) {
|
||||
} else {
|
||||
bot.commandManager.executeString(source, command)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
module.exports = command_manager;
|
||||
|
||||
+37
-81
@@ -2,7 +2,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
function filter (bot, options, config, discordClient) {
|
||||
if (options.isSavage || options.isCreayun) return;
|
||||
// filter v5 (not to be confused with the bot version)
|
||||
// filter v6 (not to be confused with the bot version)
|
||||
bot.filter = {
|
||||
list () {
|
||||
try {
|
||||
@@ -33,94 +33,50 @@ function filter (bot, options, config, discordClient) {
|
||||
},
|
||||
|
||||
doAll () {
|
||||
for (const filteredPlayers of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
if (filteredPlayers.ignoreCase) {
|
||||
check = bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase())
|
||||
} else if (filteredPlayers.regexed) {
|
||||
let regex = new RegExp(filteredPlayers.name);
|
||||
check = bot.players.find((players) => regex.test(players.profile.name))
|
||||
} else if (filteredPlayers.ignoreCase && filteredPlayers.regexed) {
|
||||
let regex = new RegExp(filteredPlayers.name.toLowerCase());
|
||||
check = bot.players.find((players) => regex.test(players.profile.name.toLowerCase()))
|
||||
} else {
|
||||
check = bot.players.find((players) => players.profile.name === filteredPlayers.name)
|
||||
}
|
||||
}
|
||||
if (!check) return;
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${check?.profile?.name}"]`)
|
||||
bot.core.run(`execute run deop @a[name="${check?.profile?.name}"]`);
|
||||
bot.core.run(`essentials:mute ${check?.uuid} 10y`);
|
||||
|
||||
}
|
||||
}
|
||||
bot.on('message', (message) => {
|
||||
bot.on('message', async (data) => {
|
||||
for (const filteredPlayer of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
// for (const eachBot of bot.bots) {
|
||||
let player_completion = (await bot.tab_complete('deop ')).filter(_ => _.tooltip == undefined);
|
||||
player_completion.forEach(async (player) => {
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
|
||||
} else {
|
||||
// if (player.match !== eachBot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) return;
|
||||
if (bot.players.find((players) => players.profile.name === player.match).profile.name === filteredPlayer.name === true) {
|
||||
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
}
|
||||
}
|
||||
})
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
|
||||
} else {
|
||||
// if (!eachBot.players.find((player) => players.profile.name === filteredPlayer.name)) return
|
||||
if (bot.players.find((players) => players.profile.name === JSON.parse(filteredPlayer.name)).gamemode !== 2) {
|
||||
// if (eachBot.players.find((player) => players.profile.name !== filteredPlayer.name)) return
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((player) => player.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
})
|
||||
bot.on('parsed_message', (data) => {
|
||||
try {
|
||||
const stringMessage = bot.getMessageAsPrismarine(message)?.toString()
|
||||
for (const filteredPlayers of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
if (filteredPlayers.ignoreCase) {
|
||||
if (!bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase())) return;
|
||||
else if (bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).gamemode !== 2) {
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).profile.name}"]`);
|
||||
} else if (stringMessage.includes('op')) {
|
||||
setTimeout(() => {
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).profile.name}"]`)
|
||||
}, 10);
|
||||
}
|
||||
} else if (filteredPlayers.regexed) {
|
||||
let regex = new RegExp(filteredPlayers.name);
|
||||
if (!bot.players.find((players) => regex.test(players.profile.name))) return;
|
||||
else if (bot.players.find((players) => regex.test(players.profile.name)).gamemode !== 2) {
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => regex.test(players.profile.name)).profile.name}"]`);
|
||||
} else if (stringMessage.includes('op')) {
|
||||
setTimeout(() => {
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => regex.test(players.profile.name)).profile.name}"]`);
|
||||
}, 10)
|
||||
}
|
||||
} else if (filteredPlayers.ignoreCase && filteredPlayers.regexed) {
|
||||
let regex = new RegExp(filteredPlayers.name.toLowerCase());
|
||||
if (!bot.players.find((players) => regex.test(players.profile.name.toLowerCase()))) return;
|
||||
else if (bot.players.find((players) => regex.test(players.profile.name.toLowerCase())).gamemode !== 2) {
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => regex.test(players.profile.name.toLowerCase())).profile.name}"]`);
|
||||
} else if (stringMessage.includes('op')) {
|
||||
setTimeout(() => {
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => regex.test(players.profile.name.toLowerCase())).profile.name}"]`);
|
||||
}, 10)
|
||||
}
|
||||
for (const filteredPlayer of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
|
||||
|
||||
} else {
|
||||
if (!bot.players.find((players) => players.profile.name === filteredPlayers.name)) return;
|
||||
else if (bot.players.find((players) => players.profile.name === filteredPlayers.name).gamemode !== 2) {
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => players.profile.name === filteredPlayers.name).profile.name}"]`);
|
||||
} else if (stringMessage.includes('op')) {
|
||||
setTimeout(() => {
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayers.name).profile.name}"]`);
|
||||
}, 10)
|
||||
if (bot?.players?.find((player) => player?.profile?.name === filteredPlayer.name)?.profile?.name === data?.sender?.profile?.name) {
|
||||
bot.core.run(`essentials:mute ${bot?.players?.find((player) => player?.profile?.name === filteredPlayer.name)?.uuid} 10y`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
bot.console.warn(e.stack);
|
||||
}
|
||||
})
|
||||
|
||||
bot.on('parsed_message', (message) => {
|
||||
const stringMessage = bot.getMessageAsPrismarine(message)?.toString();
|
||||
for (const filteredPlayers of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
if (filteredPlayers.ignoreCase) {
|
||||
check = bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase())
|
||||
} else if (filteredPlayers.regexed) {
|
||||
let regex = new RegExp(filteredPlayers.name);
|
||||
check = bot.players.find((players) => regex.test(players.profile.name))
|
||||
} else if (filteredPlayers.ignoreCase && filteredPlayers.regexed) {
|
||||
let regex = new RegExp(filteredPlayers.name.toLowerCase());
|
||||
check = bot.players.find((players) => regex.test(players.profile.name.toLowerCase()))
|
||||
} else {
|
||||
check = bot.players.find((players) => players.profile.name === filteredPlayers.name)
|
||||
}
|
||||
}
|
||||
if (bot.filter.list().length === 0) return;
|
||||
if (!check) return;
|
||||
if (!bot.players) return;
|
||||
if (message.sender.profile.name === check?.profile?.name) {
|
||||
bot.core.run(`essentials:mute ${check?.uuid} 10y`);
|
||||
console.log(e.stack);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
function player_list (bot, options, config) {
|
||||
bot.players = []
|
||||
|
||||
bot.on('packet.player_info', packet => {
|
||||
bot.on('packet.player_info', async (packet) => {
|
||||
const actions = []
|
||||
|
||||
if (packet.action & 0b000001) actions.push(addPlayer)
|
||||
if (packet.action & 0b000010) actions.push(initializeChat)
|
||||
if (packet.action & 0b000100) actions.push(updateGamemode)
|
||||
@@ -16,16 +15,15 @@ function player_list (bot, options, config) {
|
||||
action(entry)
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
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
|
||||
|
||||
const a = player_completion.filter(_ => _.match == player.profile.name)
|
||||
|
||||
if(a.length >= 1) {
|
||||
player.vanished = true
|
||||
} else {
|
||||
@@ -39,7 +37,6 @@ function player_list (bot, options, config) {
|
||||
bot.players.push({
|
||||
uuid: entry.uuid,
|
||||
profile: { name: entry.player.name, properties: entry.player.properties },
|
||||
|
||||
chatSession: undefined,
|
||||
gamemode: undefined,
|
||||
listed: undefined,
|
||||
@@ -50,7 +47,7 @@ function player_list (bot, options, config) {
|
||||
}
|
||||
|
||||
function initializeChat (entry) {
|
||||
// TODO: Handle chat sessions
|
||||
|
||||
}
|
||||
|
||||
function updateGamemode (entry) {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
const createRegistry = require('prismarine-registry')
|
||||
|
||||
function registry (bot) {
|
||||
bot.on('packet.login', packet => {
|
||||
bot.registry = createRegistry(bot._client.version)
|
||||
bot.registry.language = require('../data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = registry;
|
||||
@@ -21,6 +21,7 @@ function selfcare (bot, options, config) {
|
||||
else if (stringMessage === "Successful login!") login = false;
|
||||
else if (stringMessage === "You're already logged in!") login = false;
|
||||
else if (stringMessage === "Please, register to the server with the command: /register <password> <ConfirmPassword>") register = true;
|
||||
else if (stringMessage === "This user isn't registered!") register = true;
|
||||
else if (stringMessage === "Successfully registered!") register = false;
|
||||
// else if (stringMessage === "You already have registered this username!") register = false;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
const crypto = require("crypto");
|
||||
function validation (bot, options, config, discordClient) {
|
||||
let hashRegenInterval = setInterval(() => {
|
||||
const crypto = require('crypto')
|
||||
function validation (bot, options, config) {
|
||||
setInterval(() => {
|
||||
bot.validation = {
|
||||
trusted: crypto.createHash('sha256').update(Math.floor(Date.now() / 5000) + config.keys.trusted).digest('hex').substring(0, 16),
|
||||
admin: crypto.createHash('sha256').update(Math.floor(Date.now() / 5000) + config.keys.admin).digest('hex').substring(0, 16),
|
||||
owner: crypto.createHash('sha256').update(Math.floor(Date.now() / 5000) + config.keys.owner).digest('hex').substring(0, 16),
|
||||
trusted: crypto.createHash('sha256').update(Math.floor(Date.now() / 1000) + config.keys.trusted).digest('hex').substring(0, 16),
|
||||
admin: crypto.createHash('sha256').update(Math.floor(Date.now() / 1000) + config.keys.admin).digest('hex').substring(0, 16),
|
||||
owner: crypto.createHash('sha256').update(Math.floor(Date.now() / 1000) + config.keys.owner).digest('hex').substring(0, 16),
|
||||
}
|
||||
}, 2000)
|
||||
}, 100)
|
||||
}
|
||||
module.exports = validation;
|
||||
module.exports = validation
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
module.exports = () => {
|
||||
if (!fs.existsSync(path.join(__dirname, "../../config.yml"))) {
|
||||
console.warn("Config not found creating config from the default config");
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, "../data/default_config.yml"),
|
||||
path.join(__dirname, "../../config.yml")
|
||||
)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.join(__dirname, "../data/filter.json"))) {
|
||||
console.warn("filter json not found creating the file,......");
|
||||
let data = [{ ignoreCase: false, regexed: false, name: 'whatever player username idfk' }]
|
||||
fs.writeFileSync(path.join(__dirname, "../data/filter.json"), JSON.stringify(data))
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.join(__dirname, "../data/trustedPlayers.json"))) {
|
||||
console.warn("Trusted Players json not found creating the file,......");
|
||||
let data = [{player: ""}]
|
||||
fs.writeFileSync(path.join(__dirname, "../data/trustedPlayers.json"), JSON.stringify(data))
|
||||
}
|
||||
}
|
||||
+27
-4
@@ -1,15 +1,38 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
function loadModules (bot, options, config, discordClient) {
|
||||
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 {
|
||||
const module = require(path.join(__dirname, '../', 'modules', filename))
|
||||
bot.loadModule(module)
|
||||
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);
|
||||
}
|
||||
//bot.loadModule(module)
|
||||
} catch (error) {
|
||||
console.error('Failed to load module', filename, ':', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
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