Ver código fonte

Support news channels

closes #93
Markus-Rost 4 anos atrás
pai
commit
3e2c0698af

+ 12 - 8
bot.js

@@ -68,8 +68,12 @@ String.prototype.isMention = function(guild) {
 	return text === '@' + client.user.username || text.replace( /^<@!?(\d+)>$/, '$1' ) === client.user.id || ( guild && text === '@' + guild.me.displayName );
 };
 
+Discord.Channel.prototype.isGuild = function() {
+	return ['text', 'news'].includes( this.type );
+}
+
 Discord.Message.prototype.isAdmin = function() {
-	return this.channel.type === 'text' && this.member && ( this.member.permissions.has('MANAGE_GUILD') || ( this.isOwner() && this.evalUsed ) );
+	return this.channel.isGuild() && this.member && ( this.member.permissions.has('MANAGE_GUILD') || ( this.isOwner() && this.evalUsed ) );
 };
 
 Discord.Message.prototype.isOwner = function() {
@@ -77,11 +81,11 @@ Discord.Message.prototype.isOwner = function() {
 };
 
 Discord.Message.prototype.showEmbed = function() {
-	return this.channel.type !== 'text' || this.channel.permissionsFor(client.user).has('EMBED_LINKS');
+	return !this.channel.isGuild() || this.channel.permissionsFor(client.user).has('EMBED_LINKS');
 };
 
 Discord.Message.prototype.uploadFiles = function() {
-	return this.channel.type !== 'text' || this.channel.permissionsFor(client.user).has('ATTACH_FILES');
+	return !this.channel.isGuild() || this.channel.permissionsFor(client.user).has('ATTACH_FILES');
 };
 
 String.prototype.escapeFormatting = function(isMarkdown) {
@@ -95,7 +99,7 @@ String.prototype.replaceSave = function(pattern, replacement) {
 };
 
 Discord.Message.prototype.reactEmoji = function(name, ignorePause = false) {
-	if ( this.channel.type !== 'text' || !pause[this.guild.id] || ( ignorePause && ( this.isAdmin() || this.isOwner() ) ) ) {
+	if ( !this.channel.isGuild() || !pause[this.guild.id] || ( ignorePause && ( this.isAdmin() || this.isOwner() ) ) ) {
 		var emoji = ':error:440871715938238494';
 		switch ( name ) {
 			case 'nowiki':
@@ -119,7 +123,7 @@ Discord.MessageReaction.prototype.removeEmoji = function() {
 };
 
 Discord.Message.prototype.sendChannel = function(content, options = {}, ignorePause = false) {
-	if ( this.channel.type !== 'text' || !pause[this.guild.id] || ( ignorePause && ( this.isAdmin() || this.isOwner() ) ) ) {
+	if ( !this.channel.isGuild() || !pause[this.guild.id] || ( ignorePause && ( this.isAdmin() || this.isOwner() ) ) ) {
 		if ( !options.allowedMentions ) options.allowedMentions = {users:[this.author.id]};
 		return this.channel.send(content, options).then( msg => {
 			if ( msg.length ) msg.forEach( message => allowDelete(message, this.author.id) );
@@ -154,7 +158,7 @@ Discord.Message.prototype.sendChannelError = function(content, options = {}) {
 };
 
 Discord.Message.prototype.replyMsg = function(content, options = {}, ignorePause = false, letDelete = true) {
-	if ( this.channel.type !== 'text' || !pause[this.guild.id] || ( ignorePause && ( this.isAdmin() || this.isOwner() ) ) ) {
+	if ( !this.channel.isGuild() || !pause[this.guild.id] || ( ignorePause && ( this.isAdmin() || this.isOwner() ) ) ) {
 		if ( !options.allowedMentions ) options.allowedMentions = {users:[this.author.id]};
 		return this.reply(content, options).then( msg => {
 			if ( letDelete ) {
@@ -197,7 +201,7 @@ String.prototype.hasPrefix = function(prefix, flags = '') {
 
 client.on( 'message', msg => {
 	if ( isStop || msg.type !== 'DEFAULT' || msg.system || msg.webhookID || msg.author.bot || msg.author.id === msg.client.user.id ) return;
-	if ( !msg.content.hasPrefix(( msg.channel.type === 'text' && patreons[msg.guild.id] || process.env.prefix ), 'm') ) {
+	if ( !msg.content.hasPrefix(( msg.channel.isGuild() && patreons[msg.guild.id] || process.env.prefix ), 'm') ) {
 		if ( msg.content === process.env.prefix + 'help' && ( msg.isAdmin() || msg.isOwner() ) ) {
 			if ( msg.channel.permissionsFor(msg.client.user).has('SEND_MESSAGES') ) {
 				console.log( msg.guild.name + ': ' + msg.content );
@@ -209,7 +213,7 @@ client.on( 'message', msg => {
 		}
 		if ( !( msg.content.includes( '[[' ) && msg.content.includes( ']]' ) ) && !( msg.content.includes( '{{' ) && msg.content.includes( '}}' ) ) ) return;
 	}
-	if ( msg.channel.type === 'text' ) {
+	if ( msg.channel.isGuild() ) {
 		var permissions = msg.channel.permissionsFor(msg.client.user);
 		var missing = permissions.missing(['SEND_MESSAGES','ADD_REACTIONS','USE_EXTERNAL_EMOJIS','READ_MESSAGE_HISTORY']);
 		if ( missing.length ) {

+ 1 - 1
cmds/eval.js

@@ -151,7 +151,7 @@ function removePatreons(guild, msg) {
 function removeSettings(msg) {
 	if ( !msg ) return 'removeSettings(msg) – No message provided!';
 	try {
-		msg.client.shard.broadcastEval( `[[...this.guilds.cache.keys()], [...this.channels.cache.filter( channel => channel.type === 'text' ).keys()]]` ).then( results => {
+		msg.client.shard.broadcastEval( `[[...this.guilds.cache.keys()], [...this.channels.cache.filter( channel => channel.isGuild() ).keys()]]` ).then( results => {
 			var all_guilds = results.map( result => result[0] ).reduce( (acc, val) => acc.concat(val), [] );
 			var all_channels = results.map( result => result[1] ).reduce( (acc, val) => acc.concat(val), [] );
 			var guilds = [];

+ 2 - 2
cmds/get.js

@@ -64,7 +64,7 @@ async function cmd_get(lang, msg, args, line, wiki) {
 			} );
 		}
 		
-		var channel = await msg.client.shard.broadcastEval( `if ( this.channels.cache.filter( channel => channel.type === 'text' ).has('${id}') ) {
+		var channel = await msg.client.shard.broadcastEval( `if ( this.channels.cache.filter( channel => channel.isGuild() ).has('${id}') ) {
 			var {name, id, guild: {name: guild, id: guildID, me}} = this.channels.cache.get('${id}');
 			( {
 				name, id, guild, guildID,
@@ -137,7 +137,7 @@ async function cmd_get(lang, msg, args, line, wiki) {
 		}
 		
 		msg.replyMsg( 'I couldn\'t find a result for `' + id + '`', {}, true );
-	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
+	} else if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
 }
 
 module.exports = {

+ 5 - 5
cmds/help.js

@@ -79,7 +79,7 @@ const restrictions = {
  * @param {import('../util/wiki.js')} wiki - The wiki for the message.
  */
 function cmd_help(lang, msg, args, line, wiki) {
-	if ( msg.channel.type === 'text' && pause[msg.guild.id] && ( args.join('') || !msg.isAdmin() ) ) return;
+	if ( msg.channel.isGuild() && pause[msg.guild.id] && ( args.join('') || !msg.isAdmin() ) ) return;
 	if ( msg.isAdmin() && msg.defaultSettings ) help_server(lang, msg);
 	var isMinecraft = ( wiki.href === lang.get('minecraft.link') );
 	if ( args.join('') ) {
@@ -90,7 +90,7 @@ function cmd_help(lang, msg, args, line, wiki) {
 		var invoke = args[0].toLowerCase();
 		var cmd = ( lang.aliases[invoke] || invoke );
 		if ( cmd === 'admin' ) {
-			if ( msg.channel.type !== 'text' || msg.isAdmin() ) {
+			if ( !msg.channel.isGuild() || msg.isAdmin() ) {
 				var cmdlist = lang.get('help.admin') + '\n';
 				cmdlist += formathelp(helplist.admin, msg, lang);
 				msg.sendChannel( cmdlist, {split:{char:'🔹',prepend:'🔹'}} );
@@ -139,12 +139,12 @@ function cmd_help(lang, msg, args, line, wiki) {
  * @param {import('../util/i18n.js')} lang - The user language.
  */
 function formathelp(messages, msg, lang) {
-	var prefix = ( msg.channel.type === 'text' && patreons[msg.guild.id] || process.env.prefix );
-	var mention = '@' + ( msg.channel.type === 'text' ? msg.guild.me.displayName : msg.client.user.username );
+	var prefix = ( msg.channel.isGuild() && patreons[msg.guild.id] || process.env.prefix );
+	var mention = '@' + ( msg.channel.isGuild() ? msg.guild.me.displayName : msg.client.user.username );
 	return messages.filter( message => {
 		if ( restrictions.inline.includes( message ) && msg.noInline ) return false;
 		if ( !restrictions.patreon.includes( message ) ) return true;
-		return ( msg.channel.type === 'text' && msg.guild.id in patreons );
+		return ( msg.channel.isGuild() && msg.guild.id in patreons );
 	} ).map( message => {
 		var cmd = message.split('.')[0];
 		var intro = ( restrictions.inline.includes( message ) ? '' : prefix );

+ 2 - 2
cmds/patreon.js

@@ -11,7 +11,7 @@ var db = require('../util/database.js');
  */
 function cmd_patreon(lang, msg, args, line, wiki) {
 	if ( !( process.env.channel.split('|').includes( msg.channel.id ) && args.join('') ) ) {
-		if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
+		if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
 		return;
 	}
 	
@@ -275,7 +275,7 @@ function cmd_patreon(lang, msg, args, line, wiki) {
 		} );
 	} );
 	
-	if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
+	if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
 }
 
 module.exports = {

+ 2 - 2
cmds/pause.js

@@ -7,7 +7,7 @@
  * @param {import('../util/wiki.js')} wiki - The wiki for the message.
  */
 function cmd_pause(lang, msg, args, line, wiki) {
-	if ( msg.channel.type === 'text' && args.join(' ').split('\n')[0].isMention(msg.guild) && ( msg.isAdmin() || msg.isOwner() ) ) {
+	if ( msg.channel.isGuild() && args.join(' ').split('\n')[0].isMention(msg.guild) && ( msg.isAdmin() || msg.isOwner() ) ) {
 		if ( pause[msg.guild.id] ) {
 			delete pause[msg.guild.id];
 			console.log( '- Pause ended.' );
@@ -17,7 +17,7 @@ function cmd_pause(lang, msg, args, line, wiki) {
 			console.log( '- Pause started.' );
 			pause[msg.guild.id] = true;
 		}
-	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) {
+	} else if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) {
 		this.LINK(lang, msg, line, wiki);
 	}
 }

+ 1 - 1
cmds/stop.js

@@ -15,7 +15,7 @@ async function cmd_stop(lang, msg, args, line, wiki) {
 		await msg.replyMsg( 'I\'ll restart myself now!', {}, true );
 		console.log( '\n- Restarting all shards!\n\n' );
 		await msg.client.shard.respawnAll();
-	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) {
+	} else if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) {
 		this.LINK(lang, msg, line, wiki);
 	}
 }

+ 5 - 3
cmds/test.js

@@ -23,8 +23,9 @@ const wsStatus = [
  */
 function cmd_test(lang, msg, args, line, wiki) {
 	if ( args.join('') ) {
-		if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
-	} else if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) {
+		if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
+	}
+	else if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) {
 		if ( msg.isAdmin() && msg.defaultSettings ) help_setup(lang, msg);
 		let textList = lang.get('test.text').filter( text => text.trim() );
 		var text = textList[Math.floor(Math.random() * ( textList.length * 5 ))] || lang.get('test.text.0');
@@ -92,7 +93,8 @@ function cmd_test(lang, msg, args, line, wiki) {
 				message.edit( message.content, {embed,allowedMentions:{users:[msg.author.id]}} ).catch(log_error);
 			} );
 		} );
-	} else {
+	}
+	else {
 		console.log( '- Test: Paused!' );
 		msg.replyMsg( lang.get('test.pause'), {}, true );
 	}

+ 4 - 4
cmds/verification.js

@@ -11,7 +11,7 @@ var db = require('../util/database.js');
  */
 function cmd_verification(lang, msg, args, line, wiki) {
 	if ( !msg.isAdmin() ) {
-		if ( msg.channel.type === 'text' && !pause[msg.guild.id] ) this.verify(lang, msg, args, line, wiki);
+		if ( msg.channel.isGuild() && !pause[msg.guild.id] ) this.verify(lang, msg, args, line, wiki);
 		else msg.reactEmoji('❌');
 		return;
 	}
@@ -110,9 +110,9 @@ function cmd_verification(lang, msg, args, line, wiki) {
 				if ( channels.length > 10 ) return msg.replyMsg( lang.get('verification.channel_max'), {}, true );
 				channels = channels.map( channel => {
 					var new_channel = '';
-					if ( /^\d+$/.test(channel) ) new_channel = msg.guild.channels.cache.filter( tc => tc.type === 'text' ).get(channel);
-					if ( !new_channel ) new_channel = msg.guild.channels.cache.filter( gc => gc.type === 'text' ).find( gc => gc.name === channel.replace( /^#/, '' ) );
-					if ( !new_channel ) new_channel = msg.guild.channels.cache.filter( gc => gc.type === 'text' ).find( gc => gc.name.toLowerCase() === channel.toLowerCase().replace( /^#/, '' ) );
+					if ( /^\d+$/.test(channel) ) new_channel = msg.guild.channels.cache.filter( tc => tc.isGuild() ).get(channel);
+					if ( !new_channel ) new_channel = msg.guild.channels.cache.filter( gc => gc.isGuild() ).find( gc => gc.name === channel.replace( /^#/, '' ) );
+					if ( !new_channel ) new_channel = msg.guild.channels.cache.filter( gc => gc.isGuild() ).find( gc => gc.name.toLowerCase() === channel.toLowerCase().replace( /^#/, '' ) );
 					return new_channel;
 				} );
 				if ( channels.some( channel => !channel ) ) return msg.replyMsg( lang.get('verification.channel_missing'), {}, true );

+ 1 - 1
cmds/verify.js

@@ -15,7 +15,7 @@ var db = require('../util/database.js');
  * @param {String} [old_username] - The username before the search.
  */
 function cmd_verify(lang, msg, args, line, wiki, old_username = '') {
-	if ( msg.channel.type !== 'text' ) return this.LINK(lang, msg, line, wiki);
+	if ( !msg.channel.isGuild() ) return this.LINK(lang, msg, line, wiki);
 	if ( !msg.guild.me.permissions.has('MANAGE_ROLES') ) {
 		if ( msg.isAdmin() || msg.isOwner() ) {
 			console.log( msg.guild.id + ': Missing permissions - MANAGE_ROLES' );

+ 1 - 1
cmds/voice.js

@@ -56,7 +56,7 @@ function cmd_voice(lang, msg, args, line, wiki) {
 			} );
 		}
 	}
-	if ( msg.channel.type !== 'text' || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
+	if ( !msg.channel.isGuild() || !pause[msg.guild.id] ) this.LINK(lang, msg, line, wiki);
 }
 
 module.exports = {

+ 2 - 2
cmds/wiki/fandom.js

@@ -226,7 +226,7 @@ function fandom_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '',
 						}
 						
 						var text = '';
-						var prefix = ( msg.channel.type === 'text' && patreons[msg.guild.id] || process.env.prefix );
+						var prefix = ( msg.channel.isGuild() && patreons[msg.guild.id] || process.env.prefix );
 						var linksuffix = ( querystring.toString() ? '?' + querystring : '' ) + ( fragment ? '#' + fragment : '' );
 						if ( title.replace( /[_-]/g, ' ' ).toLowerCase() === querypage.title.replace( /-/g, ' ' ).toLowerCase() ) {
 							text = '';
@@ -405,7 +405,7 @@ function fandom_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '',
 			}
 		}
 		else if ( body.query.interwiki ) {
-			if ( msg.channel.type === 'text' && pause[msg.guild.id] ) {
+			if ( msg.channel.isGuild() && pause[msg.guild.id] ) {
 				if ( reaction ) reaction.removeEmoji();
 				console.log( '- Aborted, paused.' );
 				return;

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

@@ -149,7 +149,7 @@ function fandom_user(lang, msg, namespace, username, wiki, querystring, fragment
 							}
 						}
 						
-						if ( msg.channel.type === 'text' && msg.guild.id in patreons ) {
+						if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
 							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') + '**';
 							
@@ -299,7 +299,7 @@ function fandom_user(lang, msg, namespace, username, wiki, querystring, fragment
 							if ( discordfield && discordfield.value ) {
 								discordfield.value = htmlToPlain( discordfield.value ).replace( /^\s*([^@#:]{2,32}?)\s*#(\d{4,6})\s*$/, '$1#$2' );
 								if ( discordfield.value.length > 50 ) discordfield.value = discordfield.value.substring(0, 50) + '\u2026';
-								if ( msg.channel.type === 'text' ) var discordmember = msg.guild.members.cache.find( member => {
+								if ( msg.channel.isGuild() ) var discordmember = msg.guild.members.cache.find( member => {
 									return member.user.tag.escapeFormatting() === discordfield.value;
 								} );
 								var discordname = [lang.get('user.info.discord'),discordfield.value];
@@ -335,7 +335,7 @@ function fandom_user(lang, msg, namespace, username, wiki, querystring, fragment
 							}
 						}
 						
-						if ( msg.channel.type === 'text' && msg.guild.id in patreons ) {
+						if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
 							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
cmds/wiki/gamepedia.js

@@ -208,7 +208,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 							}
 							else embed.setThumbnail( new URL(body.query.general.logo, wiki).href );
 							
-							var prefix = ( msg.channel.type === 'text' && patreons[msg.guild.id] || process.env.prefix );
+							var prefix = ( msg.channel.isGuild() && patreons[msg.guild.id] || process.env.prefix );
 							var linksuffix = ( querystring.toString() ? '?' + querystring : '' ) + ( fragment ? '#' + fragment : '' );
 							if ( title.replace( /[_-]/g, ' ' ).toLowerCase() === querypage.title.replace( /-/g, ' ' ).toLowerCase() ) {
 								text = '';
@@ -324,7 +324,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 			}
 		}
 		else if ( body.query.interwiki ) {
-			if ( msg.channel.type === 'text' && pause[msg.guild.id] ) {
+			if ( msg.channel.isGuild() && pause[msg.guild.id] ) {
 				if ( reaction ) reaction.removeEmoji();
 				console.log( '- Aborted, paused.' );
 				return;

+ 5 - 5
cmds/wiki/gamepedia/user.js

@@ -158,7 +158,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 							} );
 						}
 						
-						if ( msg.channel.type === 'text' && msg.guild.id in patreons && ( wiki.isFandom() || wiki.isGamepedia() ) ) {
+						if ( msg.channel.isGuild() && msg.guild.id in patreons && ( wiki.isFandom() || wiki.isGamepedia() ) ) {
 							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') + '**';
 
@@ -305,7 +305,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 						else {
 							if ( pbody.profile['link-discord'] ) {
 								if ( pbody.profile['link-discord'].length > 50 ) pbody.profile['link-discord'] = pbody.profile['link-discord'].substring(0, 50) + '\u2026';
-								if ( msg.channel.type === 'text' ) var discordmember = msg.guild.members.cache.find( member => {
+								if ( msg.channel.isGuild() ) var discordmember = msg.guild.members.cache.find( member => {
 									return member.user.tag === pbody.profile['link-discord'].replace( /^\s*([^@#:]{2,32}?)\s*#(\d{4,6})\s*$/, '$1#$2' );
 								} );
 								var discordname = [lang.get('user.info.discord'),pbody.profile['link-discord'].escapeFormatting()];
@@ -340,7 +340,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 							}
 						}
 						
-						if ( msg.channel.type === 'text' && msg.guild.id in patreons ) {
+						if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
 							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') + '**';
 							
@@ -369,7 +369,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 							if ( pbody.userData.discordHandle ) {
 								let discord = pbody.userData.discordHandle.replace( /^\s*([^@#:]{2,32}?)\s*#(\d{4,6})\s*$/, '$1#$2' );
 								if ( discord.length > 50 ) discord = discord.substring(0, 50) + '\u2026';
-								if ( msg.channel.type === 'text' ) var discordmember = msg.guild.members.cache.find( member => {
+								if ( msg.channel.isGuild() ) var discordmember = msg.guild.members.cache.find( member => {
 									return member.user.tag.escapeFormatting() === discord;
 								} );
 								let discordname = [lang.get('user.info.discord'),discord];
@@ -405,7 +405,7 @@ function gamepedia_user(lang, msg, namespace, username, wiki, querystring, fragm
 							}
 						}
 						
-						if ( msg.channel.type === 'text' && msg.guild.id in patreons ) {
+						if ( msg.channel.isGuild() && msg.guild.id in patreons ) {
 							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') + '**';
 							

+ 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.type !== 'text' || !( msg.guild.id in patreons ) ) return;
+	if ( !msg || !msg.channel.isGuild() || !( msg.guild.id in patreons ) ) return;
 	
 	var isUser = true;
 	if ( !gender ) {

+ 1 - 1
functions/special_page.js

@@ -142,7 +142,7 @@ function special_page(lang, msg, title, specialpage, embed, wiki, reaction, spoi
 				if ( description.length > 2000 ) description = description.substring(0, 2000) + '\u2026';
 				embed.setDescription( description );
 			}
-			if ( msg.channel.type === 'text' && msg.guild.id in patreons && specialpage in querypages ) {
+			if ( msg.channel.isGuild() && msg.guild.id in patreons && specialpage in querypages ) {
 				var text = Util.splitMessage( querypages[specialpage][1](body.query, wiki), {maxLength:1000} )[0];
 				embed.addField( lang.get('search.special'), ( text || lang.get('search.empty') ) );
 			}

+ 1 - 1
main.js

@@ -89,7 +89,7 @@ if ( process.env.dashboard ) {
 									return {
 										botPermissions: guild.me.permissions.bitfield,
 										channels: guild.channels.cache.filter( channel => {
-											return ( channel.type === 'text' );
+											return channel.isGuild();
 										} ).sort( (a, b) => {
 											return a.rawPosition - b.rawPosition;
 										} ).map( channel => {

+ 6 - 6
util/newMessage.js

@@ -44,7 +44,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 			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] );
-			console.log( ( channel.type === 'text' ? msg.guild.id : '@' + author.id ) + ': ' + prefix + cont );
+			console.log( ( channel.isGuild() ? msg.guild.id : '@' + author.id ) + ': ' + prefix + cont );
 			return ownercmdmap[aliasInvoke](lang, msg, args, cont, wiki);
 		}
 	}
@@ -67,10 +67,10 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 		var aliasInvoke = ( lang.aliases[invoke] || invoke );
 		var ownercmd = ( msg.isOwner() && aliasInvoke in ownercmdmap );
 		var pausecmd = ( msg.isAdmin() && pause[msg.guild.id] && aliasInvoke in pausecmdmap );
-		if ( channel.type === 'text' && pause[msg.guild.id] && !( pausecmd || ownercmd ) ) {
+		if ( channel.isGuild() && pause[msg.guild.id] && !( pausecmd || ownercmd ) ) {
 			return console.log( msg.guild.id + ': Paused' );
 		}
-		console.log( ( channel.type === 'text' ? msg.guild.id : '@' + author.id ) + ': ' + prefix + line );
+		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);
@@ -99,7 +99,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 		return cmdmap.LINK(lang, msg, line, wiki);
 	} );
 	
-	if ( ( channel.type !== 'text' || !pause[msg.guild.id] ) && !noInline && ( cont.includes( '[[' ) || cont.includes( '{{' ) ) ) {
+	if ( ( !channel.isGuild() || !pause[msg.guild.id] ) && !noInline && ( cont.includes( '[[' ) || cont.includes( '{{' ) ) ) {
 		var links = [];
 		var embeds = [];
 		var linkcount = 0;
@@ -115,7 +115,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 				while ( ( entry = regex.exec(line) ) !== null ) {
 					if ( linkcount < linkmaxcount ) {
 						linkcount++;
-						console.log( ( channel.type === 'text' ? msg.guild.id : '@' + author.id ) + ': ' + entry[0] );
+						console.log( ( channel.isGuild() ? msg.guild.id : '@' + author.id ) + ': ' + entry[0] );
 						let title = entry[2].split('#')[0];
 						let section = ( entry[2].includes( '#' ) ? entry[2].split('#').slice(1).join('#') : '' )
 						links.push({title,section,spoiler:entry[1]});
@@ -135,7 +135,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 				while ( ( entry = regex.exec(line) ) !== null ) {
 					if ( count < maxcount ) {
 						count++;
-						console.log( ( channel.type === 'text' ? msg.guild.id : '@' + author.id ) + ': ' + entry[0] );
+						console.log( ( channel.isGuild() ? msg.guild.id : '@' + author.id ) + ': ' + entry[0] );
 						let title = entry[2].split('#')[0];
 						let section = ( entry[2].includes( '#' ) ? entry[2].split('#').slice(1).join('#') : '' )
 						embeds.push({title,section,spoiler:entry[1]});