ソースを参照

use hasOwnProperty

Markus-Rost 4 年 前
コミット
15119c8cd4

+ 3 - 3
bot.js

@@ -256,7 +256,7 @@ client.on( 'message', msg => {
 
 
 client.on( 'voiceStateUpdate', (olds, news) => {
-	if ( isStop || !( olds.guild.id in voice ) || !olds.guild.me.permissions.has('MANAGE_ROLES') || olds.channelID === news.channelID ) return;
+	if ( isStop || !( voice.hasOwnProperty(olds.guild.id) ) || !olds.guild.me.permissions.has('MANAGE_ROLES') || olds.channelID === news.channelID ) return;
 	var lang = new Lang(voice[olds.guild.id], 'voice');
 	if ( olds.member && olds.channel ) {
 		var oldrole = olds.member.roles.cache.find( role => role.name === lang.get('channel') + ' – ' + olds.channel.name );
@@ -290,8 +290,8 @@ client.on( 'guildDelete', guild => {
 			console.log( '- Error while removing the settings: ' + dberror );
 			return dberror;
 		}
-		if ( guild.id in patreons ) client.shard.broadcastEval( `delete global.patreons['${guild.id}']` );
-		if ( guild.id in voice ) delete voice[guild.id];
+		if ( patreons.hasOwnProperty(guild.id) ) client.shard.broadcastEval( `delete global.patreons['${guild.id}']` );
+		if ( voice.hasOwnProperty(guild.id) ) delete voice[guild.id];
 		if ( this.changes ) console.log( '- Settings successfully removed.' );
 	} );
 } );

+ 1 - 1
cmds/eval.js

@@ -282,7 +282,7 @@ function removeSettings(msg) {
 					return dberror;
 				}
 				if ( !row.channel && !all_guilds.includes(row.guild) ) {
-					if ( row.guild in patreons || row.guild in voice ) {
+					if ( patreons.hasOwnProperty(row.guild) || voice.hasOwnProperty(row.guild) ) {
 						msg.client.shard.broadcastEval( `delete global.patreons['${row.guild}'];
 						delete global.voice['${row.guild}'];` );
 					}

+ 3 - 3
cmds/get.js

@@ -21,7 +21,7 @@ async function cmd_get(lang, msg, args, line, wiki) {
 				ownerID: guild.ownerID, owner: guild.owner?.user?.tag,
 				channel: guild.publicUpdatesChannelID, icon: guild.iconURL({dynamic:true}),
 				permissions: guild.me.permissions.missing(${defaultPermissions}),
-				pause: guild.id in global.pause, voice: guild.id in global.voice,
+				pause: global.pause.hasOwnProperty(guild.id), voice: global.voice.hasOwnProperty(guild.id),
 				shardId: global.shardId
 			} )
 		}`, shardIDForGuildID(id, msg.client.shard.count) );
@@ -40,7 +40,7 @@ async function cmd_get(lang, msg, args, line, wiki) {
 				}
 				else if ( rows.length ) {
 					row = rows.find( row => !row.channel );
-					row.patreon = guild.id in patreons;
+					row.patreon = patreons.hasOwnProperty(guild.id);
 					row.voice = guild.voice;
 					guildsettings[1] = '```json\n' + JSON.stringify( rows, null, '\t' ) + '\n```';
 				}
@@ -71,7 +71,7 @@ async function cmd_get(lang, msg, args, line, wiki) {
 			( {
 				name, id, type, parentID, guild, guildID,
 				permissions: me.permissionsIn(id).missing(${defaultPermissions}),
-				pause: guildID in global.pause,
+				pause: global.pause.hasOwnProperty(guildID),
 				shardId: global.shardId
 			} )
 		}` ).then( results => results.find( result => result ) );

+ 2 - 2
cmds/help.js

@@ -106,7 +106,7 @@ function cmd_help(lang, msg, args, line, wiki) {
 			cmdlist += formathelp(helplist.minecraft, msg, lang);
 			msg.sendChannel( cmdlist, {split:{char:'\n🔹',prepend:'🔹',maxLength}} );
 		}
-		else if ( cmd in helpmap && 
+		else if ( helpmap.hasOwnProperty(cmd) && 
 		( !restrictions.fandom.includes( cmd ) || wiki.isFandom(false) ) && 
 		( !restrictions.minecraft.includes( cmd ) || isMinecraft ) && 
 		( !restrictions.admin.includes( cmd ) || msg.isAdmin() ) ) {
@@ -146,7 +146,7 @@ function formathelp(messages, msg, lang) {
 	return messages.filter( message => {
 		if ( restrictions.inline.includes( message ) && msg.noInline ) return false;
 		if ( !restrictions.patreon.includes( message ) ) return true;
-		return ( msg.channel.isGuild() && msg.guild.id in patreons );
+		return ( msg.channel.isGuild() && patreons[msg.guild.id] );
 	} ).map( message => {
 		var cmd = message.split('.')[0];
 		var intro = ( restrictions.inline.includes( message ) ? '' : prefix );

+ 1 - 1
cmds/minecraft/syntax.js

@@ -18,7 +18,7 @@ function minecraft_syntax(lang, msg, mccmd, args, title, cmd, querystring, fragm
 	mccmd = mccmd.toLowerCase();
 	var aliasCmd = ( commands.aliases[mccmd] || mccmd );
 	
-	if ( aliasCmd in commands.list ) {
+	if ( commands.list.hasOwnProperty(aliasCmd) ) {
 		var cmdSyntaxMap = commands.list[aliasCmd].map( command => {
 			var cmdargs = command.split(' ');
 			if ( cmdargs[0].startsWith( '/' ) ) cmdargs = cmdargs.slice(1);

+ 2 - 2
cmds/patreon.js

@@ -23,7 +23,7 @@ function cmd_patreon(lang, msg, args, line, wiki) {
 		}).then( invite => {
 			msg.replyMsg( 'I\'m not on a server with the id `' + args[1] + '`.\n<' + invite + '>', {}, true )
 		}, log_error );
-		if ( args[1] in patreons ) return msg.replyMsg( '"' + guild + '" has the patreon features already enabled.', {}, true );
+		if ( patreons[args[1]] ) return msg.replyMsg( '"' + guild + '" has the patreon features already enabled.', {}, true );
 		db.get( 'SELECT count, COUNT(guild) guilds FROM patreons LEFT JOIN discord ON discord.patreon = patreons.patreon WHERE patreons.patreon = ? GROUP BY patreons.patreon', [msg.author.id], (dberror, row) => {
 			if ( dberror ) {
 				console.log( '- Error while getting the patreon: ' + dberror );
@@ -58,7 +58,7 @@ function cmd_patreon(lang, msg, args, line, wiki) {
 	
 	if ( args[0] === 'disable' && /^\d+$/.test(args.slice(1).join(' ')) ) return msg.client.shard.broadcastEval( `this.guilds.cache.get('${args[1]}')?.name`, shardIDForGuildID(args[1], msg.client.shard.count) ).then( guild => {
 		if ( !guild ) return msg.replyMsg( 'I\'m not on a server with the id `' + args[1] + '`.', {}, true );
-		if ( !( args[1] in patreons ) ) return msg.replyMsg( '"' + guild + '" doesn\'t have the patreon features enabled.', {}, true );
+		if ( !patreons[args[1]] ) return msg.replyMsg( '"' + guild + '" doesn\'t have the patreon features enabled.', {}, true );
 		db.get( 'SELECT lang, inline FROM discord WHERE guild = ? AND patreon = ?', [args[1], msg.author.id], (dberror, row) => {
 			if ( dberror ) {
 				console.log( '- Error while getting the guild: ' + dberror );

+ 2 - 2
cmds/rcscript.js

@@ -39,7 +39,7 @@ function cmd_rcscript(lang, msg, args, line, wiki) {
 		var prefix = process.env.prefix;
 		var limit = rcgcdwLimit.default;
 		var display = display_types.slice(0, rcgcdwLimit.display + 1);
-		if ( msg.guild.id in patreons ) {
+		if ( patreons[msg.guild.id] ) {
 			prefix = patreons[msg.guild.id];
 			limit = rcgcdwLimit.patreon;
 			display = display_types.slice();
@@ -309,7 +309,7 @@ function cmd_rcscript(lang, msg, args, line, wiki) {
 					return msg.replyMsg( lang.get('rcscript.current_lang') + ' `' + allLangs.names[selected_row.lang] + '`\n`' + cmd + ' lang ' + lang.get('rcscript.new_lang') + '`\n' + lang.get('rcscript.help_lang') + ' `' + Object.values(allLangs.names).join('`, `') + '`', {files:( msg.uploadFiles() ? [`./RcGcDb/locale/widgets/${selected_row.lang}.png`] : [] )}, true );
 				}
 				if ( process.env.READONLY ) return msg.replyMsg( lang.get('general.readonly') + '\n' + process.env.invite, {}, true );
-				if ( !( args[1] in allLangs.map ) ) {
+				if ( !allLangs.map.hasOwnProperty(args[1]) ) {
 					return msg.replyMsg( lang.get('settings.langinvalid') + '\n`' + cmd + ' lang ' + lang.get('rcscript.new_lang') + '`\n' + lang.get('rcscript.help_lang') + ' `' + Object.values(allLangs.names).join('`, `') + '`', {}, true );
 				}
 

+ 10 - 10
cmds/settings.js

@@ -40,13 +40,13 @@ function cmd_settings(lang, msg, args, line, wiki) {
 			text = lang.get('settings.current');
 			text += `\n<${new URL(`/guild/${msg.guild.id}/settings`, process.env.dashboard).href}>`;
 			text += '\n' + lang.get('settings.currentlang') + ' `' + allLangs.names[guild.lang] + '` - `' + prefix + 'settings lang`';
-			if ( msg.guild.id in patreons ) text += '\n' + lang.get('settings.currentprefix') + ' `' + prefix + '` - `' + prefix + 'settings prefix`';
+			if ( patreons[msg.guild.id] ) text += '\n' + lang.get('settings.currentprefix') + ' `' + prefix + '` - `' + prefix + 'settings prefix`';
 			text += '\n' + lang.get('settings.currentrole') + ' ' + ( guild.role ? `<@&${guild.role}>` : '@everyone' ) + ' - `' + prefix + 'settings role`';
 			text += '\n' + lang.get('settings.currentinline') + ' ' + ( guild.inline ? '~~' : '' ) + '`[[' + inlinepage + ']]`' + ( guild.inline ? '~~' : '' ) + ' - `' + prefix + 'settings inline`';
 			text += '\n' + lang.get('settings.currentwiki') + ' ' + guild.wiki + ' - `' + prefix + 'settings wiki`';
 			text += '\n' + lang.get('settings.currentchannel') + ' `' + prefix + 'settings channel`\n';
 			if ( rows.length === 1 ) text += lang.get('settings.nochannels');
-			else text += rows.filter( row => row !== guild ).map( row => '<#' + row.channel.replace( /^#/, '' ) + '>: ' + ( msg.guild.id in patreons ? '`' + allLangs.names[row.lang] + '` - ' : '' ) + '<' + row.wiki + '>' + ( msg.guild.id in patreons ? ' - ' + ( row.role ? `<@&${row.role}>` : '@everyone' ) + ' - ' + ( row.inline ? '~~' : '' ) + '`[[' + inlinepage + ']]`' + ( row.inline ? '~~' : '' ) : '' ) ).join('\n');
+			else text += rows.filter( row => row !== guild ).map( row => '<#' + row.channel.replace( /^#/, '' ) + '>: ' + ( patreons[msg.guild.id] ? '`' + allLangs.names[row.lang] + '` - ' : '' ) + '<' + row.wiki + '>' + ( patreons[msg.guild.id] ? ' - ' + ( row.role ? `<@&${row.role}>` : '@everyone' ) + ' - ' + ( row.inline ? '~~' : '' ) + '`[[' + inlinepage + ']]`' + ( row.inline ? '~~' : '' ) : '' ) ).join('\n');
 		}
 		
 		if ( !args.length ) {
@@ -65,7 +65,7 @@ function cmd_settings(lang, msg, args, line, wiki) {
 			} ) || guild, {channel: msg.channel.id});
 			text = lang.get('settings.' + prelang + 'current');
 			text += `\n<${new URL(`/guild/${msg.guild.id}/settings/${msg.channel.id}`, process.env.dashboard).href}>`;
-			if ( msg.guild.id in patreons ) {
+			if ( patreons[msg.guild.id] ) {
 				text += '\n' + lang.get('settings.currentlang') + ' `' + allLangs.names[channel.lang] + '` - `' + prefix + 'settings channel lang`';
 				text += '\n' + lang.get('settings.currentrole') + ' ' + ( channel.role ? `<@&${channel.role}>` : '@everyone' ) + ' - `' + prefix + 'settings channel role`';
 				text += '\n' + lang.get('settings.currentinline') + ' ' + ( channel.inline ? '~~' : '' ) + '`[[' + inlinepage + ']]`' + ( channel.inline ? '~~' : '' ) + ' - `' + prefix + 'settings channel inline`';
@@ -224,14 +224,14 @@ function cmd_settings(lang, msg, args, line, wiki) {
 		}
 		
 		if ( args[0] === 'lang' ) {
-			if ( channel && !( msg.guild.id in patreons ) ) return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
+			if ( channel && !patreons[msg.guild.id] ) return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
 			prelang += 'lang';
 			var langhelp = '\n' + lang.get('settings.langhelp', prefix + 'settings ' + prelang) + ' `' + Object.values(allLangs.names).join('`, `') + '`';
 			if ( !args[1] ) {
 				return msg.replyMsg( lang.get('settings.' + prelang) + ' `' + allLangs.names[( channel || guild ).lang] + '`' + langhelp, {files:( msg.uploadFiles() ? [`./i18n/widgets/${( channel || guild ).lang}.png`] : [] )}, true );
 			}
 			if ( process.env.READONLY ) return msg.replyMsg( lang.get('general.readonly') + '\n' + process.env.invite, {}, true );
-			if ( !( args[1] in allLangs.map ) ) {
+			if ( !allLangs.map.hasOwnProperty(args[1]) ) {
 				return msg.replyMsg( lang.get('settings.langinvalid') + langhelp, {}, true );
 			}
 			var sql = 'UPDATE discord SET lang = ? WHERE guild = ? AND lang = ?';
@@ -264,9 +264,9 @@ function cmd_settings(lang, msg, args, line, wiki) {
 						if ( row.channel && row.lang === guild.lang ) row.lang = allLangs.map[args[1]];
 					} );
 					guild.lang = allLangs.map[args[1]];
-					if ( msg.guild.id in voice ) voice[msg.guild.id] = guild.lang;
+					if ( voice[msg.guild.id] ) voice[msg.guild.id] = guild.lang;
 				}
-				if ( channel || !( msg.guild.id in patreons ) || !rows.some( row => row.channel === msg.channel.id ) ) lang = new Lang(allLangs.map[args[1]]);
+				if ( channel || !patreons[msg.guild.id] || !rows.some( row => row.channel === msg.channel.id ) ) lang = new Lang(allLangs.map[args[1]]);
 				msg.replyMsg( lang.get('settings.' + prelang + 'changed') + ' `' + allLangs.names[allLangs.map[args[1]]] + '`\n' + lang.get('settings.langhelp', prefix + 'settings ' + prelang) + ' `' + Object.values(allLangs.names).join('`, `') + '`', {files:( msg.uploadFiles() ? [`./i18n/widgets/${allLangs.map[args[1]]}.png`] : [] )}, true );
 				var channels = rows.filter( row => row.channel && row.lang === guild.lang && row.wiki === guild.wiki && row.prefix === guild.prefix && row.role === guild.role && row.inline === guild.inline ).map( row => row.channel );
 				if ( channels.length ) db.run( 'DELETE FROM discord WHERE channel IN (' + channels.map( row => '?' ).join(', ') + ')', channels, function (delerror) {
@@ -280,7 +280,7 @@ function cmd_settings(lang, msg, args, line, wiki) {
 		}
 		
 		if ( args[0] === 'role' ) {
-			if ( channel && !( msg.guild.id in patreons ) ) return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
+			if ( channel && !patreons[msg.guild.id] ) return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
 			prelang += 'role';
 			var rolehelp = '\n' + lang.get('settings.rolehelp', prefix + 'settings ' + prelang);
 			if ( !args[1] ) {
@@ -346,7 +346,7 @@ function cmd_settings(lang, msg, args, line, wiki) {
 		}
 		
 		if ( args[0] === 'prefix' && !channel ) {
-			if ( !( msg.guild.id in patreons ) ) {
+			if ( !patreons[msg.guild.id] ) {
 				return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
 			}
 			var prefixhelp = '\n' + lang.get('settings.prefixhelp', prefix + 'settings prefix');
@@ -379,7 +379,7 @@ function cmd_settings(lang, msg, args, line, wiki) {
 		}
 		
 		if ( args[0] === 'inline' ) {
-			if ( channel && !( msg.guild.id in patreons ) ) return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
+			if ( channel && !patreons[msg.guild.id] ) return msg.replyMsg( lang.get('general.patreon') + '\n<' + process.env.patreon + '>', {}, true );
 			prelang += 'inline';
 			var toggle = 'inline ' + ( ( channel || guild ).inline ? 'disabled' : 'enabled' );
 			var inlinehelp = '\n' + lang.get('settings.' + toggle + '.help', prefix + 'settings ' + prelang + ' toggle', inlinepage);

+ 1 - 1
cmds/verification.js

@@ -31,7 +31,7 @@ function cmd_verification(lang, msg, args, line, wiki) {
 		
 		var prefix = ( patreons[msg.guild.id] || process.env.prefix );
 		if ( args[0] && args[0].toLowerCase() === 'add' ) {
-			var limit = verificationLimit[( msg.guild.id in patreons ? 'patreon' : 'default' )];
+			var limit = verificationLimit[( patreons[msg.guild.id] ? 'patreon' : 'default' )];
 			if ( rows.length >= limit ) return msg.replyMsg( lang.get('verification.max_entries'), {}, true );
 			if ( process.env.READONLY ) return msg.replyMsg( lang.get('general.readonly') + '\n' + process.env.invite, {}, true );
 			var roles = args.slice(1).join(' ').split('|').map( role => role.replace( /^\s*<?\s*(.*?)\s*>?\s*$/, '$1' ) ).filter( role => role.length );

+ 2 - 2
cmds/verify.js

@@ -194,8 +194,8 @@ function cmd_verify(lang, msg, args, line, wiki, old_username = '') {
 					if ( msg.author.tag.escapeFormatting() !== discordname ) {
 						embed.setColor('#FFFF00').setDescription( lang.get('verify.user_failed', msg.member.toString(), '[' + username.escapeFormatting() + '](' + pagelink + ')', queryuser.gender) );
 						var help_link = '';
-						if ( wiki.isGamepedia() ) help_link = lang.get('verify.help_gamepedia') + '?c=' + ( msg.guild.id in patreons && patreons[msg.guild.id] !== process.env.prefix ? encodeURIComponent( patreons[msg.guild.id] + ' verify' ) : 'wb' ) + ( msg.channel.name !== 'verification' ? '&ch=' + encodeURIComponent( msg.channel.name ) : '' ) + '&user=' + toTitle(username) + '&discord=' + encodeURIComponent( msg.author.username ) + '&tag=' + msg.author.discriminator;
-						else if ( wiki.isFandom() ) help_link = lang.get('verify.help_fandom') + '/' + toTitle(username) + '?c=' + ( msg.guild.id in patreons && patreons[msg.guild.id] !== process.env.prefix ? encodeURIComponent( patreons[msg.guild.id] + ' verify' ) : 'wb' ) + ( msg.channel.name !== 'verification' ? '&ch=' + encodeURIComponent( msg.channel.name ) : '' ) + '&user=' + encodeURIComponent( msg.author.username ) + '&tag=' + msg.author.discriminator;
+						if ( wiki.isGamepedia() ) help_link = lang.get('verify.help_gamepedia') + '?c=' + ( patreons[msg.guild.id] && patreons[msg.guild.id] !== process.env.prefix ? encodeURIComponent( patreons[msg.guild.id] + ' verify' ) : 'wb' ) + ( msg.channel.name !== 'verification' ? '&ch=' + encodeURIComponent( msg.channel.name ) : '' ) + '&user=' + toTitle(username) + '&discord=' + encodeURIComponent( msg.author.username ) + '&tag=' + msg.author.discriminator;
+						else if ( wiki.isFandom() ) help_link = lang.get('verify.help_fandom') + '/' + toTitle(username) + '?c=' + ( patreons[msg.guild.id] && patreons[msg.guild.id] !== process.env.prefix ? encodeURIComponent( patreons[msg.guild.id] + ' verify' ) : 'wb' ) + ( msg.channel.name !== 'verification' ? '&ch=' + encodeURIComponent( msg.channel.name ) : '' ) + '&user=' + encodeURIComponent( msg.author.username ) + '&tag=' + msg.author.discriminator;
 						if ( help_link.length ) embed.addField( lang.get('verify.notice'), lang.get('verify.help_guide', help_link, queryuser.gender) + '\n' + help_link );
 						msg.replyMsg( lang.get('verify.user_failed_reply', username.escapeFormatting(), queryuser.gender), {embed}, false, false );
 						

+ 2 - 2
cmds/voice.js

@@ -13,13 +13,13 @@ function cmd_voice(lang, msg, args, line, wiki) {
 	if ( msg.isAdmin() ) {
 		if ( !args.join('') ) {
 			var text = lang.get('voice.text') + '\n`' + lang.get('voice.channel') + ' – <' + lang.get('voice.name') + '>`\n';
-			text += lang.get('voice.' + ( msg.guild.id in voice ? 'disable' : 'enable' ), ( patreons[msg.guild.id] || process.env.prefix ) + 'voice toggle');
+			text += lang.get('voice.' + ( voice[msg.guild.id] ? 'disable' : 'enable' ), ( patreons[msg.guild.id] || process.env.prefix ) + 'voice toggle');
 			return msg.replyMsg( text, {}, true );
 		}
 		args[1] = args.slice(1).join(' ').trim()
 		if ( args[0].toLowerCase() === 'toggle' && !args[1] ) {
 			if ( process.env.READONLY ) return msg.replyMsg( lang.get('general.readonly') + '\n' + process.env.invite, {}, true );
-			var value = ( msg.guild.id in voice ? null : 1 );
+			var value = ( voice[msg.guild.id] ? null : 1 );
 			return db.run( 'UPDATE discord SET voice = ? WHERE guild = ? AND channel IS NULL', [value, msg.guild.id], function (dberror) {
 				if ( dberror ) {
 					console.log( '- Error while editing the voice settings: ' + dberror );

+ 1 - 1
cmds/wiki/fandom/general.js

@@ -418,7 +418,7 @@ function fandom_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '',
 			} );
 			if ( fragment ) iw.hash = Wiki.toSection(fragment);
 			else fragment = iw.hash.substring(1);
-			var maxselfcall = interwikiLimit[( msg?.guild?.id in patreons ? 'patreon' : 'default' )];
+			var maxselfcall = interwikiLimit[( patreons[msg.guild?.id] ? 'patreon' : 'default' )];
 			if ( selfcall < maxselfcall && ['http:','https:'].includes( iw.protocol ) ) {
 				selfcall++;
 				if ( iw.hostname.endsWith( '.fandom.com' ) || iw.hostname.endsWith( '.wikia.org' ) ) {

+ 2 - 2
cmds/wiki/fandom/user.js

@@ -149,7 +149,7 @@ function fandom_user(lang, msg, namespace, username, wiki, querystring, fragment
 							}
 						}
 						
-						if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
+						if ( msg.channel.isGuild() && patreons[msg.guild?.id] ) {
 							if ( msg.showEmbed() ) embed.addField( '\u200b', '<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**' );
 							else text += '\n\n<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**';
 							
@@ -342,7 +342,7 @@ function fandom_user(lang, msg, namespace, username, wiki, querystring, fragment
 							}
 						}
 						
-						if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
+						if ( msg.channel.isGuild() && patreons[msg.guild?.id] ) {
 							if ( msg.showEmbed() ) embed.addField( '\u200b', '<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**' );
 							else text += '\n\n<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**';
 							

+ 4 - 4
cmds/wiki/general.js

@@ -61,10 +61,10 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 	var aliasInvoke = ( lang.aliases[invoke] || invoke );
 	var args = title.split(' ').slice(1);
 	
-	if ( !msg.notMinecraft && wiki.href === lang.get('minecraft.link') && ( aliasInvoke in minecraft || invoke.startsWith( '/' ) ) ) {
+	if ( !msg.notMinecraft && wiki.href === lang.get('minecraft.link') && ( minecraft.hasOwnProperty(aliasInvoke) || invoke.startsWith( '/' ) ) ) {
 		logging(wiki, 'minecraft');
 		minecraft.WIKI = this;
-		if ( aliasInvoke in minecraft ) minecraft[aliasInvoke](lang, msg, args, title, cmd, querystring, fragment, reaction, spoiler);
+		if ( minecraft.hasOwnProperty(aliasInvoke) ) minecraft[aliasInvoke](lang, msg, args, title, cmd, querystring, fragment, reaction, spoiler);
 		else minecraft.SYNTAX(lang, msg, invoke.substring(1), args, title, cmd, querystring, fragment, reaction, spoiler);
 		return;
 	}
@@ -176,7 +176,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 				var iw_parts = querypage.title.split(':');
 				var iw = new Wiki('https://' + iw_parts[1] + '.miraheze.org/w/');
 				var iw_link = iw.toLink(iw_parts.slice(2).join(':'), querystring, fragment);
-				var maxselfcall = interwikiLimit[( msg?.guild?.id in patreons ? 'patreon' : 'default' )];
+				var maxselfcall = interwikiLimit[( patreons[msg.guild?.id] ? 'patreon' : 'default' )];
 				if ( selfcall < maxselfcall ) {
 					selfcall++;
 					return this.general(lang, msg, iw_parts.slice(2).join(':'), iw, '!!' + iw.hostname + ' ', reaction, spoiler, querystring, fragment, iw_link, selfcall);
@@ -386,7 +386,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 			} );
 			if ( fragment ) iw.hash = Wiki.toSection(fragment);
 			else fragment = iw.hash.substring(1);
-			var maxselfcall = interwikiLimit[( msg?.guild?.id in patreons ? 'patreon' : 'default' )];
+			var maxselfcall = interwikiLimit[( patreons[msg.guild?.id] ? 'patreon' : 'default' )];
 			if ( selfcall < maxselfcall && ['http:','https:'].includes( iw.protocol ) ) {
 				selfcall++;
 				if ( iw.hostname.endsWith( '.gamepedia.com' ) ) {

+ 1 - 1
cmds/wiki/search.js

@@ -24,7 +24,7 @@ function gamepedia_search(lang, msg, searchterm, wiki, query, reaction, spoiler)
 	}
 	var querypage = ( Object.values(( query.pages || {} ))?.[0] || {title:'',ns:0,invalid:''} );
 	var description = [];
-	var limit = searchLimit[( msg?.guild?.id in patreons ? 'patreon' : 'default' )];
+	var limit = searchLimit[( patreons[msg.guild?.id] ? 'patreon' : 'default' )];
 	got.get( wiki + 'api.php?action=query&titles=Special:Search&list=search&srinfo=totalhits&srprop=redirecttitle|sectiontitle&srnamespace=4|12|14|' + querypage.ns + '|' + Object.values(query.namespaces).filter( ns => ns.content !== undefined ).map( ns => ns.id ).join('|') + '&srlimit=' + limit + '&srsearch=' + encodeURIComponent( ( searchterm || ' ' ) ) + '&format=json' ).then( response => {
 		var body = response.body;
 		if ( body && body.warnings ) log_warn(body.warnings);

+ 2 - 2
cmds/wiki/user.js

@@ -168,7 +168,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 				} );
 			}
 			
-			if ( msg.channel.isGuild() && msg.guild.id in patreons && wiki.isFandom() ) {
+			if ( msg.channel.isGuild() && patreons[msg.guild?.id] && wiki.isFandom() ) {
 				if ( msg.showEmbed() ) embed.addField( '\u200b', '<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**' );
 				else text += '\n\n<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**';
 
@@ -480,7 +480,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 					}
 				}
 				
-				if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
+				if ( msg.channel.isGuild() && patreons[msg.guild?.id] ) {
 					if ( msg.showEmbed() ) embed.addField( '\u200b', '<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**' );
 					else text += '\n\n<a:loading:641343250661113886> **' + lang.get('user.info.loading') + '**';
 					

+ 2 - 2
dashboard/rcscript.js

@@ -236,7 +236,7 @@ function dashboard_rcscript(res, $, guild, args, dashboardLang) {
 			if ( args[4] === 'new' && !( process.env.READONLY || rows.length >= rcgcdwLimit[( guild.patreon ? 'patreon' : 'default' )] ) ) {
 				$('.channel#channel-new').addClass('selected');
 				createForm($, dashboardLang.get('rcscript.form.new'), dashboardLang, {
-					wiki, lang: ( lang in allLangs.names ? lang : defaultSettings.lang ),
+					wiki, lang: ( allLangs.names.hasOwnProperty(lang) ? lang : defaultSettings.lang ),
 					display: 1, patreon: guild.patreon
 				}, guild.channels, allwikis).attr('action', `/guild/${guild.id}/rcscript/new`).appendTo('#text');
 			}
@@ -284,7 +284,7 @@ function update_rcscript(res, userSettings, guild, type, settings) {
 		return res(`/guild/${guild}/rcscript/${type}`, 'savefail');
 	}
 	if ( settings.save_settings ) {
-		if ( !settings.wiki || !( settings.lang in allLangs.names ) ) {
+		if ( !settings.wiki || !allLangs.names.hasOwnProperty(settings.lang) ) {
 			return res(`/guild/${guild}/rcscript/${type}`, 'savefail');
 		}
 		if ( !['0', '1', '2', '3'].includes( settings.display ) ) {

+ 1 - 1
dashboard/settings.js

@@ -281,7 +281,7 @@ function update_settings(res, userSettings, guild, type, settings) {
 		return res(`/guild/${guild}/settings/${type}`, 'savefail');
 	}
 	if ( settings.save_settings ) {
-		if ( !settings.wiki || ( settings.lang && !( settings.lang in allLangs.names ) ) ) {
+		if ( !settings.wiki || ( settings.lang && !allLangs.names.hasOwnProperty(settings.lang) ) ) {
 			return res(`/guild/${guild}/settings/${type}`, 'savefail');
 		}
 		if ( settings.channel && !userSettings.guilds.isMember.get(guild).channels.some( channel => {

+ 1 - 1
functions/discussion.js

@@ -13,7 +13,7 @@ const {limit: {discussion: discussionLimit}} = require('../util/default.json');
  * @param {String} spoiler - If the response is in a spoiler.
  */
 function fandom_discussion(lang, msg, wiki, title, sitename, reaction, spoiler) {
-	var limit = discussionLimit[( msg?.guild?.id in patreons ? 'patreon' : 'default' )];
+	var limit = discussionLimit[( patreons[msg.guild?.id] ? 'patreon' : 'default' )];
 	if ( !title ) {
 		var pagelink = wiki + 'f';
 		var embed = new MessageEmbed().setAuthor( sitename ).setTitle( lang.get('discussion.main') ).setURL( pagelink );

+ 1 - 1
functions/global_block.js

@@ -14,7 +14,7 @@ const toTitle = require('../util/wiki.js').toTitle;
  * @param {String} [gender] - The gender of the user.
  */
 function global_block(lang, msg, username, text, embed, wiki, spoiler, gender) {
-	if ( !msg || !msg.channel.isGuild() || !( msg.guild.id in patreons ) || !wiki.isFandom() ) return;
+	if ( !msg || !msg.channel.isGuild() || !patreons[msg.guild?.id] || !wiki.isFandom() ) return;
 	
 	var isUser = true;
 	if ( !gender ) {

+ 3 - 3
functions/special_page.js

@@ -122,7 +122,7 @@ const descriptions = {
  * @param {String} spoiler - If the response is in a spoiler.
  */
 function special_page(lang, msg, title, specialpage, embed, wiki, reaction, spoiler) {
-	if ( specialpage in overwrites ) {
+	if ( overwrites.hasOwnProperty(specialpage) ) {
 		var args = title.split('/').slice(1,3);
 		overwrites[specialpage](this, lang, msg, wiki, reaction, spoiler, args, embed);
 		return;
@@ -130,7 +130,7 @@ function special_page(lang, msg, title, specialpage, embed, wiki, reaction, spoi
 	if ( specialpage === 'recentchanges' && msg.isAdmin() ) {
 		embed.addField( lang.get('rcscript.title'), lang.get('rcscript.ad', ( patreons[msg?.guild?.id] || process.env.prefix ), '[RcGcDw](https://gitlab.com/piotrex43/RcGcDw)') );
 	}
-	got.get( wiki + 'api.php?action=query&meta=allmessages&amenableparser=true&amtitle=' + encodeURIComponent( title ) + '&ammessages=' + ( specialpage in descriptions ? descriptions[specialpage] : encodeURIComponent( specialpage ) + '-summary' ) + ( specialpage in querypages ? querypages[specialpage][0] : '' ) + '&format=json' ).then( response => {
+	got.get( wiki + 'api.php?action=query&meta=allmessages&amenableparser=true&amtitle=' + encodeURIComponent( title ) + '&ammessages=' + ( descriptions.hasOwnProperty(specialpage) ? descriptions[specialpage] : encodeURIComponent( specialpage ) + '-summary' ) + ( querypages.hasOwnProperty(specialpage) ? querypages[specialpage][0] : '' ) + '&format=json' ).then( response => {
 		var body = response.body;
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( response.statusCode !== 200 || !body ) {
@@ -142,7 +142,7 @@ function special_page(lang, msg, title, specialpage, embed, wiki, reaction, spoi
 				if ( description.length > 1000 ) description = description.substring(0, 1000) + '\u2026';
 				embed.setDescription( description );
 			}
-			if ( msg.channel.isGuild() && msg.guild.id in patreons && specialpage in querypages ) {
+			if ( msg.channel.isGuild() && patreons[msg.guild?.id] && querypages.hasOwnProperty(specialpage) ) {
 				var text = Util.splitMessage( querypages[specialpage][1](body.query, wiki, lang), {maxLength:1000} )[0];
 				embed.addField( lang.get('search.special'), ( text || lang.get('search.empty') ) );
 			}

+ 4 - 0
i18n/allLangs.json

@@ -75,13 +75,16 @@
 			"汉语": "zh-hans",
 			"漢語": "zh-hant",
 			"zh-hans": "zh-hans",
+			"zh-cn": "zh-hans",
 			"chinese (simplified)": "zh-hans",
 			"simplified chinese": "zh-hans",
 			"简体中文": "zh-hans",
 			"简体中文 (zh-hans)": "zh-hans",
 			"zh-hant": "zh-hant",
+			"zh-tw": "zh-hant",
 			"chinese (traditional)": "zh-hant",
 			"traditional chinese": "zh-hant",
+			"chinese (taiwan)": "zh-hant",
 			"繁體中文": "zh-hant",
 			"繁體中文 (zh-hant)": "zh-hant"
 		}
@@ -130,6 +133,7 @@
 			"中文": "zh-hans",
 			"汉语": "zh-hans",
 			"zh-hans": "zh-hans",
+			"zh-cn": "zh-hans",
 			"chinese (simplified)": "zh-hans",
 			"simplified chinese": "zh-hans",
 			"简体中文": "zh-hans",

+ 3 - 3
main.js

@@ -91,7 +91,7 @@ if ( process.env.dashboard ) {
 								let guild = this.guilds.cache.get(id);
 								return guild.members.fetch('${message.data.member}').then( member => {
 									return {
-										patreon: guild.id in global.patreons,
+										patreon: global.patreons.hasOwnProperty(guild.id),
 										botPermissions: guild.me.permissions.bitfield,
 										channels: guild.channels.cache.filter( channel => {
 											return ( channel.isGuild() || channel.type === 'category' );
@@ -146,7 +146,7 @@ if ( process.env.dashboard ) {
 						let guild = this.guilds.cache.get('${message.data.guild}');
 						guild.members.fetch('${message.data.member}').then( member => {
 							var response = {
-								patreon: guild.id in global.patreons,
+								patreon: global.patreons.hasOwnProperty(guild.id),
 								userPermissions: member.permissions.bitfield,
 								botPermissions: guild.me.permissions.bitfield
 							};
@@ -184,7 +184,7 @@ if ( process.env.dashboard ) {
 					return manager.broadcastEval(`if ( '${( message.data.prefix || '' )}' ) {
 						global.patreons['${message.data.guild}'] = '${message.data.prefix}';
 					}
-					if ( '${( message.data.voice || '' )}' && '${message.data.guild}' in global.voice ) {
+					if ( '${( message.data.voice || '' )}' && global.voice.hasOwnProperty('${message.data.guild}') ) {
 						global.voice['${message.data.guild}'] = '${message.data.voice}';
 					}
 					if ( this.guilds.cache.has('${message.data.guild}') ) {

+ 4 - 5
util/i18n.js

@@ -25,19 +25,19 @@ class Lang {
 		this.aliases = {};
 		let aliases = ( i18n?.[lang]?.aliases || {} );
 		Object.keys(aliases).forEach( cmd => {
-			if ( aliases[cmd][0].trim() && !( cmd in this.localNames ) ) {
+			if ( aliases[cmd][0].trim() && !this.localNames.hasOwnProperty(cmd) ) {
 				this.localNames[cmd] = aliases[cmd][0];
 			}
 			aliases[cmd].forEach( alias => {
-				if ( alias.trim() && !( alias in this.aliases ) ) this.aliases[alias] = cmd;
+				if ( alias.trim() && !this.aliases.hasOwnProperty(alias) ) this.aliases[alias] = cmd;
 			} );
 		} );
 		Object.keys(defaultAliases).forEach( cmd => {
-			if ( defaultAliases[cmd][0].trim() && !( cmd in this.localNames ) ) {
+			if ( defaultAliases[cmd][0].trim() && !this.localNames.hasOwnProperty(cmd) ) {
 				this.localNames[cmd] = defaultAliases[cmd][0];
 			}
 			defaultAliases[cmd].forEach( alias => {
-				if ( alias.trim() && !( alias in this.aliases ) ) this.aliases[alias] = cmd;
+				if ( alias.trim() && !this.aliases.hasOwnProperty(alias) ) this.aliases[alias] = cmd;
 			} );
 		} );
 	}
@@ -121,7 +121,6 @@ class Lang {
 	/**
 	 * Get names for all languages.
 	 * @param {Boolean} isRcGcDw - Get the languages for RcGcDw?
-	 * @returns {{names: {en: 'English'}, map: {english: 'en'}}}
 	 * @static
 	 */
 	static allLangs(isRcGcDw = false) {

+ 5 - 5
util/newMessage.js

@@ -42,7 +42,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 	if ( msg.isOwner() && cont.hasPrefix(prefix) ) {
 		let invoke = cont.substring(prefix.length).split(' ')[0].split('\n')[0].toLowerCase();
 		let aliasInvoke = ( lang.aliases[invoke] || invoke );
-		if ( aliasInvoke in ownercmdmap ) {
+		if ( ownercmdmap.hasOwnProperty(aliasInvoke) ) {
 			cont = cont.substring(prefix.length);
 			let args = cont.split(' ').slice(1);
 			if ( cont.split(' ')[0].split('\n')[1] ) args.unshift( '', cont.split(' ')[0].split('\n')[1] );
@@ -51,7 +51,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 		}
 	}
 	var count = 0;
-	var maxcount = commandLimit[( msg?.guild?.id in patreons ? 'patreon' : 'default' )];
+	var maxcount = commandLimit[( patreons[msg.guild?.id] ? 'patreon' : 'default' )];
 	var breakLines = false;
 	cleanCont.replace( /\u200b/g, '' ).replace( /<a?(:\w+:)\d+>/g, '$1' ).replace( /(?<!\\)```.+?```/gs, '<codeblock>' ).split('\n').forEach( line => {
 		if ( line.startsWith( '>>> ' ) ) breakLines = true;
@@ -67,8 +67,8 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 		var invoke = line.split(' ')[0].toLowerCase();
 		var args = line.split(' ').slice(1);
 		var aliasInvoke = ( lang.aliases[invoke] || invoke );
-		var ownercmd = ( msg.isOwner() && aliasInvoke in ownercmdmap );
-		var pausecmd = ( msg.isAdmin() && pause[msg.guild.id] && aliasInvoke in pausecmdmap );
+		var ownercmd = ( msg.isOwner() && ownercmdmap.hasOwnProperty(aliasInvoke) );
+		var pausecmd = ( msg.isAdmin() && pause[msg.guild.id] && pausecmdmap.hasOwnProperty(aliasInvoke) );
 		if ( msg.onlyVerifyCommand && !( aliasInvoke === 'verify' || pausecmd || ownercmd ) ) return;
 		if ( channel.isGuild() && pause[msg.guild.id] && !( pausecmd || ownercmd ) ) {
 			return console.log( msg.guild.id + ': Paused' );
@@ -76,7 +76,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 		console.log( ( channel.isGuild() ? msg.guild.id : '@' + author.id ) + ': ' + prefix + line );
 		if ( ownercmd ) return ownercmdmap[aliasInvoke](lang, msg, args, line, wiki);
 		if ( pausecmd ) return pausecmdmap[aliasInvoke](lang, msg, args, line, wiki);
-		if ( aliasInvoke in cmdmap ) return cmdmap[aliasInvoke](lang, msg, args, line, wiki);
+		if ( cmdmap.hasOwnProperty(aliasInvoke) ) return cmdmap[aliasInvoke](lang, msg, args, line, wiki);
 		if ( /^![a-z\d-]{1,50}$/.test(invoke) ) {
 			return cmdmap.LINK(lang, msg, args.join(' '), new Wiki('https://' + invoke.substring(1) + '.gamepedia.com/'), invoke + ' ');
 		}