customizable config and commands dir

This commit is contained in:
ChomeNS 2022-11-06 15:30:25 +07:00
parent afe46ba633
commit bed8a6229f
5 changed files with 9 additions and 12 deletions

View file

@ -5,14 +5,13 @@ const axios = require('axios');
const util = require('util');
const querystring = require('querystring');
const {stylize} = require('../util/colors/minecraft');
const config = require('../config');
module.exports = {
name: 'eval',
alias: [],
description: 'Safe eval 100% secure!!!',
trusted: 0,
usage: '<run|reset|server> <code>',
execute: function(bot, username, usernameraw, sender, prefix, args) {
execute: function(bot, username, usernameraw, sender, prefix, args, config) {
if (args[0]==='run') {
try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)}));
@ -50,7 +49,7 @@ module.exports = {
// });
// }
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
if (args[0]==='run') {
try {
const Embed = new MessageEmbed()

View file

@ -6,6 +6,7 @@ module.exports = {
'cbot ',
'/cbot ',
],
'commandsDir': '../commands', // this will be used by the commands.js in the plugins folder so it needs ../
'keys': {
'normalKey': '<27>iB_D<5F><44><EFBFBD>k<EFBFBD><6B>j8H<38>{?[/ڭ<>f<EFBFBD><>^-=<3D>Ț<EFBFBD><C89A>v]<5D><>g><3E><>=c',
'ownerHashKey': 'b)R<><52>nF<6E>CW<43><57><EFBFBD>#<23>\\[<5B>S*8"t^eia<69>Z<EFBFBD><5A>k<EFBFBD><6B><EFBFBD><EFBFBD>K1<4B>8zȢ<7A>',

View file

@ -1,12 +1,11 @@
/* eslint-disable no-var */
/* eslint-disable max-len */
const config = require('../config');
const loadFiles = require('../util/load_files');
const path = require('path');
const {MessageEmbed} = require('discord.js');
function inject(bot, dcclient) {
function inject(bot, dcclient, config) {
function reload() {
bot.command_handler.commands = loadFiles(path.join(__dirname, '../commands'));
bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir));
}
reload();
bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc) {
@ -29,9 +28,9 @@ function inject(bot, dcclient) {
if (prefix==='!') {
if (typeof command.discordExecute==='undefined') throw new Error('This command is not yet supported on discord!');
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message);
command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config);
} else {
command.execute(bot, username, usernameraw, sender, prefix, args);
command.execute(bot, username, usernameraw, sender, prefix, args, config);
}
} catch (e) {
if (prefix==='!') {

View file

@ -1,6 +1,5 @@
/* eslint-disable max-len */
/* eslint-disable require-jsdoc */
const config = require('../config');
const nbt = require('prismarine-nbt');
const mcData = require('minecraft-data')('1.18.2');
const sleep = require('sleep-promise');
@ -9,7 +8,7 @@ const Vec3 = require('vec3');
const relativePosition = new Vec3(0, 0, 0);
function inject(bot) {
function inject(bot, dcclient, config) {
bot.createCore = (layers = config.core.layers) => {
const core = {
isCore(position) {

View file

@ -1,8 +1,7 @@
/* eslint-disable max-len */
const crypto = require('crypto');
const config = require('../config');
module.exports = {
inject: function(bot) {
inject: function(bot, dcclient, config) {
const interval = setInterval(() => {
bot.hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + config.keys.normalKey).digest('hex').substring(0, 16);
bot.ownerHash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + config.keys.ownerHashKey).digest('hex').substring(0, 16);