Markus-Rost 4 gadi atpakaļ
vecāks
revīzija
12b7becb35
2 mainītis faili ar 29 papildinājumiem un 27 dzēšanām
  1. 1 1
      cmds/rcscript.js
  2. 28 26
      util/i18n.js

+ 1 - 1
cmds/rcscript.js

@@ -50,7 +50,7 @@ function cmd_rcscript(lang, msg, args, line, wiki) {
 				console.log( msg.guild.id + ': Missing permissions - MANAGE_WEBHOOKS' );
 				return msg.replyMsg( lang.get('general.missingperm') + ' `MANAGE_WEBHOOKS`' );
 			}
-			if ( !( msg.channel.permissionsFor(msg.member).has('MANAGE_WEBHOOKS') || ( this.isOwner() && this.evalUsed ) ) ) {
+			if ( !( msg.channel.permissionsFor(msg.member).has('MANAGE_WEBHOOKS') || ( msg.isOwner() && msg.evalUsed ) ) ) {
 				return msg.replyMsg( lang.get('rcscript.noadmin') );
 			}
 			if ( rows.length >= limit ) return msg.replyMsg( lang.get('rcscript.max_entries'), {}, true );

+ 28 - 26
util/i18n.js

@@ -74,9 +74,10 @@ class Lang {
 			args.forEach( (arg, i) => {
 				text = text.replaceSave( new RegExp( `\\$${i + 1}`, 'g' ), arg );
 			} );
-			text = text.replace( /{{\s*GENDER:\s*([a-z]+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, type, cases) => {
+			if ( text.includes( 'GENDER:' ) ) text = text.replace( /{{\s*GENDER:\s*([a-z]+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, type, cases) => {
 				return gender(type, cases.split(/\s*\|\s*/));
-			} ).replace( /{{\s*PLURAL:\s*[+-]?(\d+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, number, cases) => {
+			} );
+			if ( text.includes( 'PLURAL:' ) ) text = text.replace( /{{\s*PLURAL:\s*[+-]?(\d+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, number, cases) => {
 				return plural(lang, parseInt(number, 10), cases.split(/\s*\|\s*/));
 			} );
 		}
@@ -106,9 +107,10 @@ class Lang {
 //			args.forEach( (arg, i) => {
 //				text = text.replaceSave( new RegExp( `\\$${i + 1}`, 'g' ), arg );
 //			} );
-//			text = text.replace( /{{\s*GENDER:\s*([a-z]+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, type, cases) => {
+//			if ( text.includes( 'GENDER:' ) ) text = text.replace( /{{\s*GENDER:\s*([a-z]+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, type, cases) => {
 //				return gender(type, cases.split(/\s*\|\s*/));
-//			} ).replace( /{{\s*PLURAL:\s*[+-]?(\d+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, number, cases) => {
+//			} );
+//			if ( text.includes( 'PLURAL:' ) ) text = text.replace( /{{\s*PLURAL:\s*[+-]?(\d+)\s*\|\s*([^\{\}]*?)\s*}}/g, (m, number, cases) => {
 //				return plural(lang, parseInt(number, 10), cases.split(/\s*\|\s*/));
 //			} );
 //		}
@@ -127,6 +129,28 @@ class Lang {
 	}
 }
 
+/**
+ * Parse gender text.
+ * @param {String} gender - The gender.
+ * @param {String[]} args - The possible text.
+ * @returns {String}
+ */
+function gender(gender, args) {
+	var text = args[0];
+	switch ( gender ) {
+		case 'male':
+			if ( args.length > 0 ) text = args[0];
+			break;
+		case 'female':
+			if ( args.length > 1 ) text = args[1];
+			break;
+		case 'unknown':
+		default:
+			if ( args.length > 2 ) text = args[2];
+	}
+	return text;
+}
+
 /**
  * Parse plural text.
  * @param {String} lang - The language code.
@@ -188,26 +212,4 @@ function getArg(args, index) {
 	return ( args.length > index ? args[index] : args[args.length - 1] );
 }
 
-/**
- * Parse gender text.
- * @param {String} gender - The gender.
- * @param {String[]} args - The possible text.
- * @returns {String}
- */
-function gender(gender, args) {
-	var text = args[0];
-	switch ( gender ) {
-		case 'male':
-			if ( args.length > 0 ) text = args[0];
-			break;
-		case 'female':
-			if ( args.length > 1 ) text = args[1];
-			break;
-		case 'unknown':
-		default:
-			if ( args.length > 2 ) text = args[2];
-	}
-	return text;
-}
-
 module.exports = Lang;