Markus-Rost преди 6 години
родител
ревизия
e5b9258e7d
променени са 1 файла, в които са добавени 69 реда и са изтрити 67 реда
  1. 69 67
      main.js

+ 69 - 67
main.js

@@ -17,7 +17,7 @@ var multiManager = require('./wiki_manager.json');
 
 
 var pause = {};
 var pause = {};
 var stop = false;
 var stop = false;
-var isDebug = ( process.argv[2] === 'debug' ? true : false );
+var isDebug = ( process.argv[2] === 'debug' );
 const access = {'PRIVATE-TOKEN': process.env.access};
 const access = {'PRIVATE-TOKEN': process.env.access};
 const defaultPermissions = new Discord.Permissions(268954688).toArray();
 const defaultPermissions = new Discord.Permissions(268954688).toArray();
 const timeoptions = {
 const timeoptions = {
@@ -52,12 +52,13 @@ function getSettings() {
 		json: true
 		json: true
 	}, function( error, response, body ) {
 	}, function( error, response, body ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.message || body.error ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.message || body.error ) {
-			console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the settings' + ( error ? ': ' + error : ( body ? ( body.message ? ': ' + body.message : ( body.error ? ': ' + body.error : '.' ) ) : '.' ) ) );
+			console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the settings: ' + ( error || body && ( body.message || body.error ) ) );
 			ready.settings = false;
 			ready.settings = false;
 		}
 		}
 		else {
 		else {
 			console.log( '- Settings successfully loaded.' );
 			console.log( '- Settings successfully loaded.' );
-			settings = JSON.parse(JSON.stringify(body));
+			if ( body.default ) settings = JSON.parse(JSON.stringify(body));
+			else if ( settings === defaultSettings ) settings = JSON.parse(JSON.stringify(defaultSettings));
 		}
 		}
 		setStatus();
 		setStatus();
 	} );
 	} );
@@ -80,7 +81,7 @@ function getAllSites() {
 		json: true
 		json: true
 	}, function( error, response, body ) {
 	}, function( error, response, body ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.status !== 'okay' || !body.data || !body.data.wikis ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.status !== 'okay' || !body.data || !body.data.wikis ) {
-			console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while gettings all sites' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+			console.log( '- ' + ( response && response.statusCode ) + ': Error while gettings all sites: ' + ( error || body && body.error && body.error.info ) );
 			ready.allSites = false;
 			ready.allSites = false;
 		}
 		}
 		else {
 		else {
@@ -223,7 +224,7 @@ function find_wikis(lang, msg, key, value, text) {
 				json: true
 				json: true
 			}, function( error, response, body ) {
 			}, function( error, response, body ) {
 				if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !( body instanceof Object ) ) {
 				if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !( body instanceof Object ) ) {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while reaching the wiki' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+					console.log( '- ' + ( response && response.statusCode ) + ': Error while reaching the wiki: ' + ( error || body && body.error && body.error.info ) );
 					msg.reactEmoji('nowiki', true);
 					msg.reactEmoji('nowiki', true);
 					if ( reaction ) reaction.removeEmoji();
 					if ( reaction ) reaction.removeEmoji();
 				}
 				}
@@ -252,7 +253,7 @@ function edit_settings(lang, msg, key, value) {
 			var temp_settings = JSON.parse(JSON.stringify(settings));
 			var temp_settings = JSON.parse(JSON.stringify(settings));
 			var save = false;
 			var save = false;
 			if ( !( msg.guild.id in temp_settings ) ) {
 			if ( !( msg.guild.id in temp_settings ) ) {
-				temp_settings[msg.guild.id] = Object.assign({}, settings['default']);
+				temp_settings[msg.guild.id] = Object.assign({}, settings.default);
 				save = true;
 				save = true;
 			}
 			}
 			if ( key === 'channel' ) {
 			if ( key === 'channel' ) {
@@ -302,7 +303,7 @@ function edit_settings(lang, msg, key, value) {
 				json: true
 				json: true
 			}, function( error, response, body ) {
 			}, function( error, response, body ) {
 				if ( error || !response || response.statusCode !== 201 || !body || body.error ) {
 				if ( error || !response || response.statusCode !== 201 || !body || body.error ) {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while editing the settings' + ( error ? ': ' + error : ( body ? ( body.message ? ': ' + body.message : ( body.error ? ': ' + body.error : '.' ) ) : '.' ) ) );
+					console.log( '- ' + ( response || response.statusCode ) + ': Error while editing the settings: ' + ( error || body && ( body.message || body.error ) ) );
 					msg.replyMsg( lang.settings.save_failed, {}, true );
 					msg.replyMsg( lang.settings.save_failed, {}, true );
 				}
 				}
 				else {
 				else {
@@ -326,9 +327,7 @@ function edit_settings(lang, msg, key, value) {
 function cmd_info(lang, msg, args, line) {
 function cmd_info(lang, msg, args, line) {
 	if ( args.join('') ) cmd_link(lang, msg, line.split(' ').slice(1).join(' '));
 	if ( args.join('') ) cmd_link(lang, msg, line.split(' ').slice(1).join(' '));
 	else {
 	else {
-		var owner = '*MarkusRost*';
-		if ( msg.channel.type === 'text' && msg.guild.members.has(process.env.owner) ) owner = '<@' + process.env.owner + '>';
-		msg.sendChannel( lang.disclaimer.replaceSave( '%s', owner ) );
+		msg.sendChannel( lang.disclaimer.replaceSave( '%s', ( msg.channel.type === 'text' && msg.guild.members.get(process.env.owner) || '*MarkusRost*' ) ) );
 		cmd_helpserver(lang, msg);
 		cmd_helpserver(lang, msg);
 		cmd_invite(lang, msg, args, line);
 		cmd_invite(lang, msg, args, line);
 	}
 	}
@@ -345,7 +344,7 @@ function cmd_help(lang, msg, args, line) {
 		cmd_helpserver(lang, msg);
 		cmd_helpserver(lang, msg);
 	}
 	}
 	var cmds = lang.help.list;
 	var cmds = lang.help.list;
-	var isMinecraft = ( lang.link === minecraft[lang.lang].link );
+	var isMinecraft = ( msg.channel.getWiki() === minecraft[lang.lang].link );
 	var cmdintro = '🔹 `' + process.env.prefix + ' ';
 	var cmdintro = '🔹 `' + process.env.prefix + ' ';
 	if ( args.join('') ) {
 	if ( args.join('') ) {
 		if ( args.join(' ').isMention(msg.guild) ) cmd_helpserver(lang, msg);
 		if ( args.join(' ').isMention(msg.guild) ) cmd_helpserver(lang, msg);
@@ -422,8 +421,7 @@ function cmd_umfrage(lang, msg, args, line) {
 			if ( !custom.test(reaction) && ( reaction.length > 4 || pattern.test(reaction) ) ) {
 			if ( !custom.test(reaction) && ( reaction.length > 4 || pattern.test(reaction) ) ) {
 				cmd_sendumfrage(lang, msg, args.slice(i).join(' ').replace( /^\n| (\n)/, '$1' ), reactions, imgs);
 				cmd_sendumfrage(lang, msg, args.slice(i).join(' ').replace( /^\n| (\n)/, '$1' ), reactions, imgs);
 				break;
 				break;
-			} else if ( reaction === '' ) {
-			} else {
+			} else if ( reaction !== '' ) {
 				if ( custom.test(reaction) ) {
 				if ( custom.test(reaction) ) {
 					reaction = reaction.substring(reaction.lastIndexOf(':') + 1, reaction.length - 1);
 					reaction = reaction.substring(reaction.lastIndexOf(':') + 1, reaction.length - 1);
 				}
 				}
@@ -464,9 +462,7 @@ function cmd_test(lang, msg, args, line) {
 	if ( args.join('') ) {
 	if ( args.join('') ) {
 		if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) cmd_link(lang, msg, line.split(' ').slice(1).join(' '));
 		if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) cmd_link(lang, msg, line.split(' ').slice(1).join(' '));
 	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) {
 	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) {
-		var text = lang.test.default;
-		var x = Math.floor(Math.random() * lang.test.random);
-		if ( x < lang.test.text.length ) text = lang.test.text[x];
+		var text = lang.test.text[Math.floor(Math.random() * lang.test.random)] || lang.test.default;
 		console.log( '- Test: Fully functioning!' );
 		console.log( '- Test: Fully functioning!' );
 		var now = Date.now();
 		var now = Date.now();
 		msg.replyMsg( text ).then( edit => {
 		msg.replyMsg( text ).then( edit => {
@@ -474,7 +470,7 @@ function cmd_test(lang, msg, args, line) {
 			var embed = new Discord.RichEmbed().setTitle( lang.test.time ).addField( 'Discord', ( then - now ) + 'ms' );
 			var embed = new Discord.RichEmbed().setTitle( lang.test.time ).addField( 'Discord', ( then - now ) + 'ms' );
 			now = Date.now();
 			now = Date.now();
 			request( {
 			request( {
-				uri: lang.link + 'api.php?action=query&format=json',
+				uri: msg.channel.getWiki() + 'api.php?action=query&format=json',
 				json: true
 				json: true
 			}, function( error, response, body ) {
 			}, function( error, response, body ) {
 				then = Date.now();
 				then = Date.now();
@@ -482,15 +478,15 @@ function cmd_test(lang, msg, args, line) {
 				var ping = ( then - now ) + 'ms';
 				var ping = ( then - now ) + 'ms';
 				if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !( body instanceof Object ) ) {
 				if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !( body instanceof Object ) ) {
 					if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 					if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-						console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+						console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info || '' ) );
 						ping += ' <:unknown_wiki:505887262077353984>';
 						ping += ' <:unknown_wiki:505887262077353984>';
 					}
 					}
 					else {
 					else {
-						console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while reaching the wiki' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+						console.log( '- ' + ( response && response.statusCode ) + ': Error while reaching the wiki: ' + ( error || body && body.error && body.error.info ) );
 						ping += ' <:error:505887261200613376>';
 						ping += ' <:error:505887261200613376>';
 					}
 					}
 				}
 				}
-				embed.addField( lang.link, ping );
+				embed.addField( msg.channel.getWiki(), ping );
 				if ( edit ) edit.edit( edit.content, embed ).catch(log_error);
 				if ( edit ) edit.edit( edit.content, embed ).catch(log_error);
 			} );
 			} );
 		} );
 		} );
@@ -571,7 +567,7 @@ function cmd_delete(lang, msg, args, line) {
 	}
 	}
 }
 }
 
 
-function cmd_link(lang, msg, title, wiki = lang.link, cmd = ' ') {
+function cmd_link(lang, msg, title, wiki = msg.channel.getWiki(), cmd = ' ') {
 	if ( cmd === ' ' && msg.isAdmin() && !( msg.guild.id in settings ) && settings !== defaultSettings ) {
 	if ( cmd === ' ' && msg.isAdmin() && !( msg.guild.id in settings ) && settings !== defaultSettings ) {
 		cmd_settings(lang, msg, [], '');
 		cmd_settings(lang, msg, [], '');
 	}
 	}
@@ -601,7 +597,7 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 	var args = title.split(' ').slice(1);
 	var args = title.split(' ').slice(1);
 	
 	
 	var mclang = minecraft[lang.lang];
 	var mclang = minecraft[lang.lang];
-	var aliasInvoke = ( invoke in mclang.aliase ? mclang.aliase[invoke] : invoke );
+	var aliasInvoke = ( mclang.aliase[invoke] || invoke );
 	if ( !msg.notminecraft && wiki === mclang.link && ( aliasInvoke in minecraftcmdmap || invoke.startsWith( '/' ) ) ) {
 	if ( !msg.notminecraft && wiki === mclang.link && ( aliasInvoke in minecraftcmdmap || invoke.startsWith( '/' ) ) ) {
 		if ( aliasInvoke in minecraftcmdmap ) minecraftcmdmap[aliasInvoke](lang, mclang, msg, args, title, cmd, querystring, fragment, reaction, spoiler);
 		if ( aliasInvoke in minecraftcmdmap ) minecraftcmdmap[aliasInvoke](lang, mclang, msg, args, title, cmd, querystring, fragment, reaction, spoiler);
 		else cmd_befehl(lang, mclang, msg, invoke.substring(1), args, title, cmd, querystring, fragment, reaction, spoiler);
 		else cmd_befehl(lang, mclang, msg, invoke.substring(1), args, title, cmd, querystring, fragment, reaction, spoiler);
@@ -627,11 +623,11 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 			if ( body && body.warnings ) log_warn(body.warnings);
 			if ( body && body.warnings ) log_warn(body.warnings);
 			if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query ) {
 			if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query ) {
 				if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 				if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-					console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+					console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 					msg.reactEmoji('nowiki');
 					msg.reactEmoji('nowiki');
 				}
 				}
 				else {
 				else {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+					console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 					msg.sendChannelError( spoiler + '<' + wiki.toLink() + ( linksuffix || !title ? title.toTitle() + linksuffix : 'Special:Search?search=' + title.toSearch() ) + '>' + spoiler );
 					msg.sendChannelError( spoiler + '<' + wiki.toLink() + ( linksuffix || !title ? title.toTitle() + linksuffix : 'Special:Search?search=' + title.toSearch() ) + '>' + spoiler );
 				}
 				}
 				
 				
@@ -667,7 +663,7 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 							json: true
 							json: true
 						}, function( uerror, uresponse, ubody ) {
 						}, function( uerror, uresponse, ubody ) {
 							if ( uerror || !uresponse || uresponse.statusCode !== 200 || !ubody || ubody.batchcomplete === undefined || !ubody.query ) {
 							if ( uerror || !uresponse || uresponse.statusCode !== 200 || !ubody || ubody.batchcomplete === undefined || !ubody.query ) {
-								console.log( '- ' + ( uresponse ? uresponse.statusCode + ': ' : '' ) + 'Error while getting the user' + ( uerror ? ': ' + uerror : ( ubody ? ( ubody.error ? ': ' + ubody.error.info : '.' ) : '.' ) ) );
+								console.log( '- ' + ( uresponse && uresponse.statusCode ) + ': Error while getting the user: ' + ( uerror || ubody && ubody.error && ubody.error.info ) );
 								msg.sendChannelError( spoiler + '<' + wiki.toLink() + ( contribs + username ).toTitle() + linksuffix + '>' + spoiler );
 								msg.sendChannelError( spoiler + '<' + wiki.toLink() + ( contribs + username ).toTitle() + linksuffix + '>' + spoiler );
 								
 								
 								if ( reaction ) reaction.removeEmoji();
 								if ( reaction ) reaction.removeEmoji();
@@ -698,7 +694,7 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 						}, function( srerror, srresponse, srbody ) {
 						}, function( srerror, srresponse, srbody ) {
 							if ( srbody && srbody.warnings ) log_warn(srbody.warnings);
 							if ( srbody && srbody.warnings ) log_warn(srbody.warnings);
 							if ( srerror || !srresponse || srresponse.statusCode !== 200 || !srbody || srbody.batchcomplete === undefined ) {
 							if ( srerror || !srresponse || srresponse.statusCode !== 200 || !srbody || srbody.batchcomplete === undefined ) {
-								console.log( '- ' + ( srresponse ? srresponse.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( srerror ? ': ' + srerror : ( srbody ? ( srbody.error ? ': ' + srbody.error.info : '.' ) : '.' ) ) );
+								console.log( '- ' + ( srresponse && srresponse.statusCode ) + ': Error while getting the search results: ' + ( srerror || srbody && srbody.error && srbody.error.info ) );
 								msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Search?search=' + title.toSearch() + '>' + spoiler );
 								msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Search?search=' + title.toSearch() + '>' + spoiler );
 							}
 							}
 							else {
 							else {
@@ -752,15 +748,15 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 										if ( querypage.categoryinfo.size === 0 ) category.push(langCat.empty);
 										if ( querypage.categoryinfo.size === 0 ) category.push(langCat.empty);
 										if ( querypage.categoryinfo.pages > 0 ) {
 										if ( querypage.categoryinfo.pages > 0 ) {
 											var pages = querypage.categoryinfo.pages;
 											var pages = querypage.categoryinfo.pages;
-											category.push(langCat.pages[( pages in langCat.pages ? pages : 'default' )].replaceSave( '%s', pages ));
+											category.push(( langCat.pages[pages] || langCat.pages.default ).replaceSave( '%s', pages ));
 										}
 										}
 										if ( querypage.categoryinfo.files > 0 ) {
 										if ( querypage.categoryinfo.files > 0 ) {
 											var files = querypage.categoryinfo.files;
 											var files = querypage.categoryinfo.files;
-											category.push(langCat.files[( files in langCat.files ? files : 'default' )].replaceSave( '%s', files ));
+											category.push(( langCat.files[files] || langCat.files.default ).replaceSave( '%s', files ));
 										}
 										}
 										if ( querypage.categoryinfo.subcats > 0 ) {
 										if ( querypage.categoryinfo.subcats > 0 ) {
 											var subcats = querypage.categoryinfo.subcats;
 											var subcats = querypage.categoryinfo.subcats;
-											category.push(langCat.subcats[( subcats in langCat.subcats ? subcats : 'default' )].replaceSave( '%s', subcats ));
+											category.push(( langCat.subcats[subcats] || langCat.subcats.default ).replaceSave( '%s', subcats ));
 										}
 										}
 										if ( msg.showEmbed() ) embed.addField( category[0], category.slice(1).join('\n') );
 										if ( msg.showEmbed() ) embed.addField( category[0], category.slice(1).join('\n') );
 										else text += '\n\n' + category.join('\n');
 										else text += '\n\n' + category.join('\n');
@@ -808,15 +804,15 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 							if ( querypage.categoryinfo.size === 0 ) category.push(langCat.empty);
 							if ( querypage.categoryinfo.size === 0 ) category.push(langCat.empty);
 							if ( querypage.categoryinfo.pages > 0 ) {
 							if ( querypage.categoryinfo.pages > 0 ) {
 								var pages = querypage.categoryinfo.pages;
 								var pages = querypage.categoryinfo.pages;
-								category.push(langCat.pages[( pages in langCat.pages ? pages : 'default' )].replaceSave( '%s', pages ));
+								category.push(( langCat.pages[pages] || langCat.pages.default ).replaceSave( '%s', pages ));
 							}
 							}
 							if ( querypage.categoryinfo.files > 0 ) {
 							if ( querypage.categoryinfo.files > 0 ) {
 								var files = querypage.categoryinfo.files;
 								var files = querypage.categoryinfo.files;
-								category.push(langCat.files[( files in langCat.files ? files : 'default' )].replaceSave( '%s', files ));
+								category.push(( langCat.files[files] || langCat.files.default ).replaceSave( '%s', files ));
 							}
 							}
 							if ( querypage.categoryinfo.subcats > 0 ) {
 							if ( querypage.categoryinfo.subcats > 0 ) {
 								var subcats = querypage.categoryinfo.subcats;
 								var subcats = querypage.categoryinfo.subcats;
-								category.push(langCat.subcats[( subcats in langCat.subcats ? subcats : 'default' )].replaceSave( '%s', subcats ));
+								category.push(( langCat.subcats[subcats] || langCat.subcats.default ).replaceSave( '%s', subcats ));
 							}
 							}
 							if ( msg.showEmbed() ) embed.addField( category[0], category.slice(1).join('\n') );
 							if ( msg.showEmbed() ) embed.addField( category[0], category.slice(1).join('\n') );
 							else text += '\n\n' + category.join('\n');
 							else text += '\n\n' + category.join('\n');
@@ -852,13 +848,13 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 								console.log( '- Aborted, paused.' );
 								console.log( '- Aborted, paused.' );
 							}
 							}
 						} else {
 						} else {
+							if ( fragment ) fragment = '#' + fragment.toSection();
 							if ( inter.url.includes( '#' ) ) {
 							if ( inter.url.includes( '#' ) ) {
 								if ( !fragment ) fragment = '#' + inter.url.split('#').slice(1).join('#');
 								if ( !fragment ) fragment = '#' + inter.url.split('#').slice(1).join('#');
-								else fragment = '#' + fragment.toSection();
 								inter.url = inter.url.split('#')[0];
 								inter.url = inter.url.split('#')[0];
 							}
 							}
-							if ( querystring ) inter.url += ( inter.url.includes( '?' ) ? '&' : '?' ) + querystring.toTitle() + fragment;
-							msg.sendChannel( spoiler + ' ' + inter.url.replace( /@(here|everyone)/g, '%40$1' ) + ' ' + spoiler ).then( message => {
+							if ( querystring ) inter.url += ( inter.url.includes( '?' ) ? '&' : '?' ) + querystring.toTitle();
+							msg.sendChannel( spoiler + ' ' + inter.url.replace( /@(here|everyone)/g, '%40$1' ) + fragment + ' ' + spoiler ).then( message => {
 								if ( message && selfcall === 5 ) message.reactEmoji('⚠');
 								if ( message && selfcall === 5 ) message.reactEmoji('⚠');
 							} );
 							} );
 							if ( reaction ) reaction.removeEmoji();
 							if ( reaction ) reaction.removeEmoji();
@@ -874,7 +870,7 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 					}, function( mperror, mpresponse, mpbody ) {
 					}, function( mperror, mpresponse, mpbody ) {
 						if ( mpbody && mpbody.warnings ) log_warn(body.warnings);
 						if ( mpbody && mpbody.warnings ) log_warn(body.warnings);
 						if ( mperror || !mpresponse || mpresponse.statusCode !== 200 || !mpbody || mpbody.batchcomplete === undefined || !mpbody.query ) {
 						if ( mperror || !mpresponse || mpresponse.statusCode !== 200 || !mpbody || mpbody.batchcomplete === undefined || !mpbody.query ) {
-							console.log( '- ' + ( mpresponse ? mpresponse.statusCode + ': ' : '' ) + 'Error while getting the main page' + ( mperror ? ': ' + mperror : ( mpbody ? ( mpbody.error ? ': ' + mpbody.error.info : '.' ) : '.' ) ) );
+							console.log( '- ' + ( mpresponse && mpresponse.statusCode ) + ': Error while getting the main page: ' + ( mperror || mpbody && mpbody.error && mpbody.error.info ) );
 						} else {
 						} else {
 							querypage = Object.values(mpbody.query.pages)[0];
 							querypage = Object.values(mpbody.query.pages)[0];
 							if ( querypage.pageprops && querypage.pageprops.displaytitle ) embed.setTitle( querypage.pageprops.displaytitle.escapeFormatting() );
 							if ( querypage.pageprops && querypage.pageprops.displaytitle ) embed.setTitle( querypage.pageprops.displaytitle.escapeFormatting() );
@@ -916,7 +912,7 @@ function cmd_user(lang, msg, namespace, username, wiki, linksuffix, querypage, c
 			if ( body && body.warnings ) log_warn(body.warnings);
 			if ( body && body.warnings ) log_warn(body.warnings);
 			if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.blocks ) {
 			if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.blocks ) {
 				if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 				if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-					console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+					console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 					msg.reactEmoji('nowiki');
 					msg.reactEmoji('nowiki');
 				}
 				}
 				else if ( body && body.error && ( body.error.code === 'param_ip' || body.error.code === 'cidrtoobroad' ) ) {
 				else if ( body && body.error && ( body.error.code === 'param_ip' || body.error.code === 'cidrtoobroad' ) ) {
@@ -939,7 +935,7 @@ function cmd_user(lang, msg, namespace, username, wiki, linksuffix, querypage, c
 					}
 					}
 				}
 				}
 				else {
 				else {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+					console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 					msg.sendChannelError( spoiler + '<' + wiki.toLink() + ( querypage.noRedirect ? namespace : contribs ) + username.toTitle() + linksuffix + '>' + spoiler );
 					msg.sendChannelError( spoiler + '<' + wiki.toLink() + ( querypage.noRedirect ? namespace : contribs ) + username.toTitle() + linksuffix + '>' + spoiler );
 				}
 				}
 				
 				
@@ -991,7 +987,7 @@ function cmd_user(lang, msg, namespace, username, wiki, linksuffix, querypage, c
 							msg.reactEmoji('error');
 							msg.reactEmoji('error');
 						}
 						}
 						else {
 						else {
-							console.log( '- ' + ( ucresponse ? ucresponse.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( ucerror ? ': ' + ucerror : ( ucbody ? ( ucbody.error ? ': ' + ucbody.error.info : '.' ) : '.' ) ) );
+							console.log( '- ' + ( ucresponse && ucresponse.statusCode ) + ': Error while getting the search results: ' + ( ucerror || ucbody && ucbody.error && ucbody.error.info ) );
 							msg.sendChannelError( spoiler + '<' + wiki.toLink() + namespace + username.toTitle() + linksuffix + '>' + spoiler );
 							msg.sendChannelError( spoiler + '<' + wiki.toLink() + namespace + username.toTitle() + linksuffix + '>' + spoiler );
 						}
 						}
 					}
 					}
@@ -1025,11 +1021,11 @@ function cmd_user(lang, msg, namespace, username, wiki, linksuffix, querypage, c
 			if ( body && body.warnings ) log_warn(body.warnings);
 			if ( body && body.warnings ) log_warn(body.warnings);
 			if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.users[0] ) {
 			if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.users[0] ) {
 				if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 				if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-					console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+					console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 					msg.reactEmoji('nowiki');
 					msg.reactEmoji('nowiki');
 				}
 				}
 				else {
 				else {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+					console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 					msg.sendChannelError( spoiler + '<' + wiki.toLink() + namespace + username.toTitle() + linksuffix + '>' + spoiler );
 					msg.sendChannelError( spoiler + '<' + wiki.toLink() + namespace + username.toTitle() + linksuffix + '>' + spoiler );
 				}
 				}
 			}
 			}
@@ -1110,7 +1106,7 @@ function cmd_user(lang, msg, namespace, username, wiki, linksuffix, querypage, c
 						json: true
 						json: true
 					}, function( perror, presponse, pbody ) {
 					}, function( perror, presponse, pbody ) {
 						if ( perror || !presponse || presponse.statusCode !== 200 || !pbody || pbody.error || pbody.errormsg || !pbody.profile ) {
 						if ( perror || !presponse || presponse.statusCode !== 200 || !pbody || pbody.error || pbody.errormsg || !pbody.profile ) {
-							console.log( '- ' + ( presponse ? presponse.statusCode + ': ' : '' ) + 'Error while getting the user profile' + ( perror ? ': ' + perror : ( pbody ? ( pbody.error ? ': ' + pbody.error.info : ': ' + pbody.errormsg ) : '.' ) ) );
+							console.log( '- ' + ( presponse && presponse.statusCode ) + ': Error while getting the user profile: ' + ( perror || pbody && ( pbody.error && pbody.error.info || pbody.errormsg ) ) );
 						}
 						}
 						else if ( pbody.profile['link-discord'] ) {
 						else if ( pbody.profile['link-discord'] ) {
 							var discordmember = msg.guild.members.find( member => member.user.tag === pbody.profile['link-discord'] );
 							var discordmember = msg.guild.members.find( member => member.user.tag === pbody.profile['link-discord'] );
@@ -1214,14 +1210,14 @@ function cmd_diff(lang, msg, args, wiki, reaction, spoiler) {
 						}
 						}
 					}
 					}
 					if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 					if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-						console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+						console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 						msg.reactEmoji('nowiki');
 						msg.reactEmoji('nowiki');
 					}
 					}
 					else if ( noerror ) {
 					else if ( noerror ) {
 						msg.replyMsg( lang.diff.badrev );
 						msg.replyMsg( lang.diff.badrev );
 					}
 					}
 					else {
 					else {
-						console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+						console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 						msg.sendChannelError( spoiler + '<' + wiki.toLink() + title.toTitle() + '?diff=' + relative + ( title ? '' : '&oldid=' + revision ) + '>' + spoiler );
 						msg.sendChannelError( spoiler + '<' + wiki.toLink() + title.toTitle() + '?diff=' + relative + ( title ? '' : '&oldid=' + revision ) + '>' + spoiler );
 					}
 					}
 					
 					
@@ -1345,11 +1341,11 @@ function cmd_diffsend(lang, msg, args, wiki, reaction, spoiler, compare) {
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query ) {
 			if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 			if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-				console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+				console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 				msg.reactEmoji('nowiki');
 				msg.reactEmoji('nowiki');
 			}
 			}
 			else {
 			else {
-				console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+				console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 				msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Diff/' + ( args[1] ? args[1] + '/' : '' ) + args[0] + '>' + spoiler );
 				msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Diff/' + ( args[1] ? args[1] + '/' : '' ) + args[0] + '>' + spoiler );
 			}
 			}
 			
 			
@@ -1429,7 +1425,7 @@ function cmd_diffsend(lang, msg, args, wiki, reaction, spoiler, compare) {
 											noerror = false;
 											noerror = false;
 									}
 									}
 								}
 								}
-								if ( !noerror ) console.log( '- ' + ( cpresponse ? cpresponse.statusCode + ': ' : '' ) + 'Error while getting the diff' + ( cperror ? ': ' + cperror : ( cpbody ? ( cpbody.error ? ': ' + cpbody.error.info : '.' ) : '.' ) ) );
+								if ( !noerror ) console.log( '- ' + ( cpresponse && cpresponse.statusCode ) + ': Error while getting the diff: ' + ( cperror || cpbody && cpbody.error && cpbody.error.info ) );
 							}
 							}
 							else if ( cpbody.compare.fromtexthidden === undefined && cpbody.compare.totexthidden === undefined && cpbody.compare.fromarchive === undefined && cpbody.compare.toarchive === undefined ) {
 							else if ( cpbody.compare.fromtexthidden === undefined && cpbody.compare.totexthidden === undefined && cpbody.compare.fromarchive === undefined && cpbody.compare.toarchive === undefined ) {
 								var current_tag = '';
 								var current_tag = '';
@@ -1580,11 +1576,11 @@ function cmd_random(lang, msg, wiki, reaction, spoiler) {
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.pages ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.pages ) {
 			if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 			if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-				console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+				console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 				msg.reactEmoji('nowiki');
 				msg.reactEmoji('nowiki');
 			}
 			}
 			else {
 			else {
-				console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+				console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 				msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Random>' + spoiler );
 				msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Random>' + spoiler );
 			}
 			}
 		}
 		}
@@ -1630,11 +1626,11 @@ function cmd_overview(lang, msg, wiki, reaction, spoiler) {
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.pages ) {
 		if ( error || !response || response.statusCode !== 200 || !body || body.batchcomplete === undefined || !body.query || !body.query.pages ) {
 			if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
 			if ( response && response.request && response.request.uri && response.request.uri.href === 'https://www.gamepedia.com/' ) {
-				console.log( '- This wiki doesn\'t exist! ' + ( error ? error.message : ( body ? ( body.error ? body.error.info : '' ) : '' ) ) );
+				console.log( '- This wiki doesn\'t exist! ' + ( error || body && body.error && body.error.info ) );
 				msg.reactEmoji('nowiki');
 				msg.reactEmoji('nowiki');
 			}
 			}
 			else {
 			else {
-				console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the search results' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+				console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the search results: ' + ( error || body && body.error && body.error.info ) );
 				msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Statistics>' + spoiler );
 				msg.sendChannelError( spoiler + '<' + wiki.toLink() + 'Special:Statistics>' + spoiler );
 			}
 			}
 		}
 		}
@@ -1693,12 +1689,12 @@ function cmd_bug(lang, mclang, msg, args, title, cmd, querystring, fragment, rea
 						msg.sendChannel( spoiler + mclang.bug.private + '\n<' + link + project + invoke + '>' + spoiler );
 						msg.sendChannel( spoiler + mclang.bug.private + '\n<' + link + project + invoke + '>' + spoiler );
 					}
 					}
 					else {
 					else {
-						console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the issue: ' + body.errorMessages.join(' - ') );
+						console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the issue: ' + body.errorMessages.join(' - ') );
 						msg.reactEmoji('error');
 						msg.reactEmoji('error');
 					}
 					}
 				}
 				}
 				else {
 				else {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the issue' + ( error ? ': ' + error : ( body ? ': ' + body.message : '.' ) ) );
+					console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the issue: ' + ( error || body && body.message ) );
 					if ( body && body['status-code'] === 404 ) msg.reactEmoji('error');
 					if ( body && body['status-code'] === 404 ) msg.reactEmoji('error');
 					else msg.sendChannelError( spoiler + '<' + link + project + invoke + '>' + spoiler );
 					else msg.sendChannelError( spoiler + '<' + link + project + invoke + '>' + spoiler );
 				}
 				}
@@ -1747,12 +1743,12 @@ function cmd_bug(lang, mclang, msg, args, title, cmd, querystring, fragment, rea
 						msg.reactEmoji('🤷');
 						msg.reactEmoji('🤷');
 					}
 					}
 					else {
 					else {
-						console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the issues: ' + body.errorMessages.join(' - ') );
+						console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the issues: ' + body.errorMessages.join(' - ') );
 						msg.reactEmoji('error');
 						msg.reactEmoji('error');
 					}
 					}
 				}
 				}
 				else {
 				else {
-					console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while getting the issues' + ( error ? ': ' + error : ( body ? ': ' + body.message : '.' ) ) );
+					console.log( '- ' + ( response && response.statusCode ) + ': Error while getting the issues: ' + ( error || body && body.message ) );
 					if ( body && body['status-code'] === 404 ) msg.reactEmoji('error');
 					if ( body && body['status-code'] === 404 ) msg.reactEmoji('error');
 					else msg.sendChannelError( spoiler + '<' + link + '>' + spoiler );
 					else msg.sendChannelError( spoiler + '<' + link + '>' + spoiler );
 				}
 				}
@@ -1786,7 +1782,8 @@ function cmd_bug(lang, mclang, msg, args, title, cmd, querystring, fragment, rea
 }
 }
 
 
 function cmd_befehl(lang, mclang, msg, befehl, args, title, cmd, querystring, fragment, reaction, spoiler) {
 function cmd_befehl(lang, mclang, msg, befehl, args, title, cmd, querystring, fragment, reaction, spoiler) {
-	var aliasCmd = ( ( befehl in minecraft.cmd.aliase ) ? minecraft.cmd.aliase[befehl] : befehl ).toLowerCase();
+	befehl = befehl.toLowerCase();
+	var aliasCmd = ( minecraft.cmd.aliase[befehl] || befehl );
 	
 	
 	if ( aliasCmd in minecraft.cmd.list ) {
 	if ( aliasCmd in minecraft.cmd.list ) {
 		var regex = new RegExp('/' + aliasCmd, 'g');
 		var regex = new RegExp('/' + aliasCmd, 'g');
@@ -1867,7 +1864,7 @@ function cmd_get(lang, msg, args, line) {
 			var channelguild = ['Guild:', channel.guild.name.escapeFormatting() + ' `' + channel.guild.id + '`' + ( pause[channel.guild.id] ? '\\*' : '' )];
 			var channelguild = ['Guild:', channel.guild.name.escapeFormatting() + ' `' + channel.guild.id + '`' + ( pause[channel.guild.id] ? '\\*' : '' )];
 			var channelname = ['Channel:', '#' + channel.name.escapeFormatting() + ' `' + channel.id + '` ' + channel.toString()];
 			var channelname = ['Channel:', '#' + channel.name.escapeFormatting() + ' `' + channel.id + '` ' + channel.toString()];
 			var channelpermissions = ['Missing permissions:', ( channel.memberPermissions(channel.guild.me).has(defaultPermissions) ? '*none*' : '`' + channel.memberPermissions(channel.guild.me).missing(defaultPermissions).join('`, `') + '`' )];
 			var channelpermissions = ['Missing permissions:', ( channel.memberPermissions(channel.guild.me).has(defaultPermissions) ? '*none*' : '`' + channel.memberPermissions(channel.guild.me).missing(defaultPermissions).join('`, `') + '`' )];
-			var channelwiki = ['Default Wiki:', ( channel.guild.id in settings ? ( settings[channel.guild.id].channels && channel.id in settings[channel.guild.id].channels ? settings[channel.guild.id].channels[channel.id] : settings[channel.guild.id].wiki ) : settings['default'].wiki )];
+			var channelwiki = ['Default Wiki:', channel.getWiki()];
 			if ( msg.showEmbed() ) {
 			if ( msg.showEmbed() ) {
 				var text = '';
 				var text = '';
 				var embed = new Discord.RichEmbed().addField( channelguild[0], channelguild[1] ).addField( channelname[0], channelname[1] ).addField( channelpermissions[0], channelpermissions[1] ).addField( channelwiki[0], channelwiki[1] );
 				var embed = new Discord.RichEmbed().addField( channelguild[0], channelguild[1] ).addField( channelname[0], channelname[1] ).addField( channelpermissions[0], channelpermissions[1] ).addField( channelwiki[0], channelwiki[1] );
@@ -1891,6 +1888,14 @@ String.prototype.isMention = function(guild) {
 	return text === '@' + client.user.username || text.replace( /^<@!?(\d+)>$/, '$1' ) === client.user.id || ( guild && text === '@' + guild.me.displayName );
 	return text === '@' + client.user.username || text.replace( /^<@!?(\d+)>$/, '$1' ) === client.user.id || ( guild && text === '@' + guild.me.displayName );
 };
 };
 
 
+Discord.Channel.prototype.getWiki = function() {
+	if ( this.type === 'text' && this.guild.id in settings ) {
+		if ( settings[this.guild.id].channels && this.id in settings[this.guild.id].channels ) return settings[this.guild.id].channels[this.id];
+		else return settings[this.guild.id].wiki;
+	}
+	else return settings.default.wiki;
+};
+
 Discord.Message.prototype.isAdmin = function() {
 Discord.Message.prototype.isAdmin = function() {
 	return this.channel.type === 'text' && this.member && this.member.permissions.has('MANAGE_GUILD');
 	return this.channel.type === 'text' && this.member && this.member.permissions.has('MANAGE_GUILD');
 };
 };
@@ -1967,7 +1972,7 @@ String.prototype.toPlaintext = function() {
 };
 };
 
 
 String.prototype.escapeFormatting = function() {
 String.prototype.escapeFormatting = function() {
-	return this.replace( /(`|_|\*|~|<|>|{|}|@|\||\/\/)/g, '\\$1' );
+	return this.replace( /(`|_|\*|~|<|>|{|}|@|\||\\|\/\/)/g, '\\$1' );
 };
 };
 
 
 String.prototype.replaceSave = function(pattern, replacement) {
 String.prototype.replaceSave = function(pattern, replacement) {
@@ -2062,17 +2067,14 @@ client.on( 'message', msg => {
 	
 	
 	if ( !ready.settings && settings === defaultSettings ) getSettings();
 	if ( !ready.settings && settings === defaultSettings ) getSettings();
 	if ( !ready.allSites && !allSites.length ) getAllSites();
 	if ( !ready.allSites && !allSites.length ) getAllSites();
-	var setting = Object.assign({}, settings['default']);
 	if ( settings === defaultSettings ) {
 	if ( settings === defaultSettings ) {
 		msg.sendChannel( '⚠ **Limited Functionality** ⚠\nNo settings found, please contact the bot owner!\n' + process.env.invite, {}, true );
 		msg.sendChannel( '⚠ **Limited Functionality** ⚠\nNo settings found, please contact the bot owner!\n' + process.env.invite, {}, true );
-	} else if ( channel.type === 'text' && msg.guild.id in settings ) setting = Object.assign({}, settings[msg.guild.id]);
-	var lang = Object.assign({}, i18n[setting.lang]);
-	lang.link = setting.wiki;
-	if ( setting.channels && channel.id in setting.channels ) lang.link = setting.channels[channel.id];
+	}
+	var lang = i18n[( channel.type === 'text' && settings[msg.guild.id] || settings.default ).lang];
 	
 	
 	if ( channel.type !== 'text' || permissions.has(['SEND_MESSAGES','ADD_REACTIONS','USE_EXTERNAL_EMOJIS','READ_MESSAGE_HISTORY']) ) {
 	if ( channel.type !== 'text' || permissions.has(['SEND_MESSAGES','ADD_REACTIONS','USE_EXTERNAL_EMOJIS','READ_MESSAGE_HISTORY']) ) {
 		var invoke = ( cont.split(' ')[1] ? cont.split(' ')[1].split('\n')[0].toLowerCase() : '' );
 		var invoke = ( cont.split(' ')[1] ? cont.split(' ')[1].split('\n')[0].toLowerCase() : '' );
-		var aliasInvoke = ( invoke in lang.aliase ? lang.aliase[invoke] : invoke );
+		var aliasInvoke = ( lang.aliase[invoke] || invoke );
 		var ownercmd = ( msg.isOwner() && aliasInvoke in ownercmdmap );
 		var ownercmd = ( msg.isOwner() && aliasInvoke in ownercmdmap );
 		if ( cont.hasPrefix() && ( ( msg.isAdmin() && aliasInvoke in multilinecmdmap ) || ownercmd ) ) {
 		if ( cont.hasPrefix() && ( ( msg.isAdmin() && aliasInvoke in multilinecmdmap ) || ownercmd ) ) {
 			if ( ownercmd || permissions.has('MANAGE_MESSAGES') ) {
 			if ( ownercmd || permissions.has('MANAGE_MESSAGES') ) {
@@ -2093,7 +2095,7 @@ client.on( 'message', msg => {
 					count++;
 					count++;
 					invoke = ( line.split(' ')[1] ? line.split(' ')[1].toLowerCase() : '' );
 					invoke = ( line.split(' ')[1] ? line.split(' ')[1].toLowerCase() : '' );
 					var args = line.split(' ').slice(2);
 					var args = line.split(' ').slice(2);
-					aliasInvoke = ( invoke in lang.aliase ? lang.aliase[invoke] : invoke );
+					aliasInvoke = ( lang.aliase[invoke] || invoke );
 					ownercmd = ( msg.isOwner() && aliasInvoke in ownercmdmap );
 					ownercmd = ( msg.isOwner() && aliasInvoke in ownercmdmap );
 					if ( channel.type === 'text' && pause[msg.guild.id] && !( ( msg.isAdmin() && aliasInvoke in pausecmdmap ) || ownercmd ) ) console.log( msg.guild.name + ': Paused' );
 					if ( channel.type === 'text' && pause[msg.guild.id] && !( ( msg.isAdmin() && aliasInvoke in pausecmdmap ) || ownercmd ) ) console.log( msg.guild.name + ': Paused' );
 					else console.log( ( msg.guild ? msg.guild.name : '@' + author.username ) + ': ' + line );
 					else console.log( ( msg.guild ? msg.guild.name : '@' + author.username ) + ': ' + line );
@@ -2125,7 +2127,7 @@ client.on( 'voiceStateUpdate', (oldm, newm) => {
 	if ( !ready.settings && settings === defaultSettings ) getSettings();
 	if ( !ready.settings && settings === defaultSettings ) getSettings();
 	if ( !ready.allSites && !allSites.length ) getAllSites();
 	if ( !ready.allSites && !allSites.length ) getAllSites();
 	if ( oldm.guild.me.permissions.has('MANAGE_ROLES') && oldm.voiceChannelID !== newm.voiceChannelID ) {
 	if ( oldm.guild.me.permissions.has('MANAGE_ROLES') && oldm.voiceChannelID !== newm.voiceChannelID ) {
-		var lang = i18n[settings[( oldm.guild.id in settings ? oldm.guild.id : 'default' )].lang].voice;
+		var lang = i18n[( settings[oldm.guild.id] || settings.default ).lang].voice;
 		if ( oldm.voiceChannel ) {
 		if ( oldm.voiceChannel ) {
 			var oldrole = oldm.roles.find( role => role.name === lang.channel + ' – ' + oldm.voiceChannel.name );
 			var oldrole = oldm.roles.find( role => role.name === lang.channel + ' – ' + oldm.voiceChannel.name );
 			if ( oldrole && oldrole.comparePositionTo(oldm.guild.me.highestRole) < 0 ) {
 			if ( oldrole && oldrole.comparePositionTo(oldm.guild.me.highestRole) < 0 ) {
@@ -2184,7 +2186,7 @@ client.on( 'guildDelete', guild => {
 			json: true
 			json: true
 		}, function( error, response, body ) {
 		}, function( error, response, body ) {
 			if ( error || !response || response.statusCode !== 201 || !body || body.error ) {
 			if ( error || !response || response.statusCode !== 201 || !body || body.error ) {
-				console.log( '- ' + ( response ? response.statusCode + ': ' : '' ) + 'Error while removing the settings' + ( error ? ': ' + error : ( body ? ( body.message ? ': ' + body.message : ( body.error ? ': ' + body.error : '.' ) ) : '.' ) ) );
+				console.log( '- ' + ( response && response.statusCode ) + ': Error while removing the settings: ' + ( error || body && ( body.message || body.error ) ) );
 			}
 			}
 			else {
 			else {
 				settings = JSON.parse(JSON.stringify(temp_settings));
 				settings = JSON.parse(JSON.stringify(temp_settings));