meocord
Version:
MeoCord is a lightweight and modular framework for building scalable Discord bots using TypeScript and Discord.js. It simplifies bot development with an extensible architecture, TypeScript-first approach, and powerful CLI tools.
17 lines • 5.1 kB
JavaScript
function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
* MeoCord Framework
* Copyright (C) 2025 Ukasyah Rahmatullah Zada
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/import{inspect}from"node:util";import dayjs from"dayjs";import utc from"dayjs/plugin/utc.js";import timezone from"dayjs/plugin/timezone.js";import{loadMeoCordConfig}from"../util/meocord-config-loader.util.js";import chalk from"chalk";dayjs.extend(utc),dayjs.extend(timezone);export var Logger=/*#__PURE__*/function(){function Logger(a){_classCallCheck(this,Logger),_defineProperty(this,"colorMap",{LOG:chalk.green,INFO:chalk.cyan,WARN:chalk.yellow,ERROR:chalk.red,DEBUG:chalk.magenta}),this.context=a}return _createClass(Logger,[{key:"log",value:function log(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("log",b)}},{key:"info",value:function info(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("log",b)}},{key:"warn",value:function warn(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("warn",b)}},{key:"error",value:function error(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("error",b)}},{key:"debug",value:function debug(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("debug",b)}},{key:"verbose",value:function verbose(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("log",b)}},{key:"formatMessage",value:function formatMessage(a,b){return"object"===_typeof(a)&&null!==a?inspect(a,{showHidden:!0,depth:null,colors:!0,compact:!1,showProxy:!0}):(this.colorMap[b]||function(a){return a})(a)}},{key:"logWithContext",value:function logWithContext(a,b){var c,d=this;if(0!==b.length){var e=loadMeoCordConfig(),f=a.toUpperCase(),g=this.colorMap[f]||function(a){return a},h=b.map(function(a){return d.formatMessage(a,f)}),i=null!==e&&void 0!==e&&e.appName?g(chalk.bold("[".concat(e.appName,"]"))):void 0,j=chalk.bold(dayjs().format("dddd, MMMM D, YYYY HH:mm:ss [UTC]Z")),k=g(chalk.bold("[".concat(f,"]"))),l=this.context?chalk.yellow.bold("[".concat(this.context,"]")):"",m=[i,j,k,l].concat(_toConsumableArray(h)).filter(function(a){return!!a});(c=console)[a].apply(c,_toConsumableArray(m))}}}])}();