Kaynağa Gözat

Multiple improvements

Markus-Rost 4 yıl önce
ebeveyn
işleme
559162f71c

+ 2 - 2
README.md

@@ -1,7 +1,7 @@
 # Wiki-Bot[<img src="https://translate.wikibot.de/widgets/wiki-bot/-/svg-badge.svg" alt="Translation status" align="right" />](#translations)[<img src="https://github.com/Markus-Rost/discord-wiki-bot/workflows/Node.js CI/badge.svg" alt="Node.js CI" align="right" />](https://github.com/Markus-Rost/discord-wiki-bot/actions)
 [<img src="/dashboard/src/icon.png" alt="Wiki-Bot" align="right" />](https://discord.com/oauth2/authorize?client_id=461189216198590464&permissions=939904064&scope=bot%20applications.commands)
 
-**Wiki-Bot** is a bot for [Discord](https://discord.com/) with the purpose to easily link and search [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki) sites like [Gamepedia](https://www.gamepedia.com/) and [Fandom](https://www.fandom.com/) wikis. **Wiki-Bot** shows short descriptions and additional info about pages and is able to resolve redirects and follow interwiki links.
+**Wiki-Bot** is a bot for [Discord](https://discord.com/) with the purpose to easily link and search [MediaWiki](https://www.mediawiki.org/wiki/MediaWiki) sites like [Wikipedia](https://www.wikipedia.org/) and [Fandom](https://www.fandom.com/) wikis. **Wiki-Bot** shows short descriptions and additional info about pages and is able to resolve redirects and follow interwiki links.
 
 **Wiki-Bot** has translations for English, Bengali, German, French, Hindi, Dutch, Polish, Portuguese, Russian, Turkish and Chinese.
 
@@ -22,7 +22,7 @@ Support server: [https://discord.gg/v77RTk5](https://discord.gg/v77RTk5)
 ## Setup
 After [inviting](https://discord.com/oauth2/authorize?client_id=461189216198590464&permissions=939904064&scope=bot%20applications.commands) **Wiki-Bot** to your server you need to set the wiki you want to search by default. You do this with the `!wiki settings` command.
 * Change the wiki with `!wiki settings wiki <url>`
-  * Example: `!wiki settings wiki https://minecraft.gamepedia.com/Minecraft_Wiki`
+  * Example: `!wiki settings wiki https://minecraft.fandom.com/Minecraft_Wiki`
 * Change the language with `!wiki settings lang <language>`
   * Example: `!wiki settings lang German`
 

+ 37 - 10
cmds/eval.js

@@ -186,21 +186,48 @@ function removePatreons(guild, msg) {
 				console.log( '- Error while updating the guild: ' + dberror );
 				messages.push('Error while updating the guild: ' + dberror);
 				return Promise.reject();
+			} ).then( () => {
+				return client.query( 'DELETE FROM discord WHERE guild = $1 AND channel LIKE $2 RETURNING channel, wiki', [guild, '#%'] ).then( ({rows}) => {
+					if ( rows.length ) {
+						console.log( '- Channel categories successfully deleted.' );
+						messages.push('Channel categories successfully deleted.');
+						return msg.client.shard.broadcastEval( `if ( this.guilds.cache.has('${guild}') ) {
+							let rows = ${JSON.stringify(rows)};
+							this.guilds.cache.get('${guild}').channels.cache.filter( channel => {
+								return ( channel.isGuild() && rows.some( row => {
+									return ( row.channel === '#' + channel.parentID );
+								} ) );
+							} ).map( channel => {
+								return {
+									id: channel.id,
+									wiki: rows.find( row => {
+										return ( row.channel === '#' + channel.parentID );
+									} ).wiki
+								};
+							} )
+						}`, Discord.ShardClientUtil.shardIDForGuildID(guild, msg.client.shard.count) ).then( channels => {
+							if ( channels.length ) return Promise.all(channels.map( channel => {
+								return client.query( 'INSERT INTO discord(wiki, guild, channel, lang, role, inline, prefix) VALUES($1, $2, $3, $4, $5, $6, $7)', [channel.wiki, guild, channel.id, row.lang, row.role, row.inline, process.env.prefix] ).catch( dberror => {
+									if ( dberror.message !== 'duplicate key value violates unique constraint "discord_guild_channel_key"' ) {
+										console.log( '- Error while adding category settings to channels: ' + dberror );
+									}
+								} );
+							} ));
+						}, error => {
+							console.log( '- Error while getting the channels in categories: ' + error );
+							messages.push('Error while getting the channels in categories: ' + error);
+						} );
+					}
+				}, dberror => {
+					console.log( '- Error while deleting the channel categories: ' + dberror );
+					messages.push('Error while deleting the channel categories: ' + dberror);
+					return Promise.reject();
+				} );
 			} );
 		}, dberror => {
 			console.log( '- Error while getting the guild: ' + dberror );
 			messages.push('Error while getting the guild: ' + dberror);
 			return Promise.reject();
-		} ).then( () => {
-			return client.query( 'DELETE FROM discord WHERE guild = $1 AND channel LIKE $2', [guild, '#%'] ).then( ({rowCount}) => {
-				if ( rowCount ) {
-					console.log( '- Channel categories successfully deleted.' );
-					messages.push('Channel categories successfully deleted.');
-				}
-			}, dberror => {
-				console.log( '- Error while deleting the channel categories: ' + dberror );
-				messages.push('Error while deleting the channel categories: ' + dberror);
-			} );
 		} ).then( () => {
 			return client.query( 'SELECT configid FROM verification WHERE guild = $1 ORDER BY configid ASC OFFSET $2', [guild, verificationLimit.default] ).then( ({rows}) => {
 				if ( rows.length ) {

+ 1 - 1
cmds/help.js

@@ -104,7 +104,7 @@ function cmd_help(lang, msg, args, line, wiki) {
 			}
 		}
 		else if ( cmd === 'minecraft' ) {
-			var cmdlist = '<' + ( isMinecraft ? wiki : 'https://minecraft.gamepedia.com/' ) + '>\n';
+			var cmdlist = '<' + ( isMinecraft ? wiki : 'https://minecraft.fandom.com/' ) + '>\n';
 			cmdlist += formathelp(helplist.minecraft, msg, lang);
 			msg.sendChannel( cmdlist, {split:{char:'\n🔹',prepend:'🔹',maxLength}} );
 		}

+ 13 - 13
cmds/minecraft/commands.json

@@ -1,18 +1,18 @@
 {
 	"wikis": {
-		"https://minecraft.gamepedia.com/": "Commands/",
-		"https://minecraft-de.gamepedia.com/": "Befehl/",
-		"https://minecraft-es.gamepedia.com/": "Comandos/",
-		"https://minecraft-fr.gamepedia.com/": "Commandes",
-		"https://minecraft-it.gamepedia.com/": "Comandi/",
-		"https://minecraft-ja.gamepedia.com/": "コマンド/",
-		"https://minecraft-ko.gamepedia.com/": "명령어",
-		"https://minecraft-nl.gamepedia.com/": "Opdrachten/",
-		"https://minecraft-pl.gamepedia.com/": "Komendy/",
-		"https://minecraft-pt.gamepedia.com/": "Comandos/",
-		"https://minecraft-ru.gamepedia.com/": "Команды консоли/",
-		"https://minecraft-uk.gamepedia.com/": "Команди консолі/",
-		"https://minecraft-zh.gamepedia.com/": "命令/"
+		"https://minecraft.fandom.com/": "Commands/",
+		"https://minecraft.fandom.com/de/": "Befehl/",
+		"https://minecraft.fandom.com/es/": "Comandos/",
+		"https://minecraft.fandom.com/fr/": "Commandes",
+		"https://minecraft.fandom.com/it/": "Comandi/",
+		"https://minecraft.fandom.com/ja/": "コマンド/",
+		"https://minecraft.fandom.com/ko/": "명령어",
+		"https://minecraft.fandom.com/nl/": "Opdrachten/",
+		"https://minecraft.fandom.com/pl/": "Komendy/",
+		"https://minecraft.fandom.com/pt/": "Comandos/",
+		"https://minecraft.fandom.com/ru/": "Команды консоли/",
+		"https://minecraft.fandom.com/uk/": "Команди консолі/",
+		"https://minecraft.fandom.com/zh/": "命令/"
 	},
 	"aliases": {
 		"connect": "wsserver",

+ 2 - 2
cmds/minecraft/syntax.js

@@ -42,7 +42,7 @@ function minecraft_syntax(lang, msg, wiki, mccmd, args, title, cmd, reaction, sp
 			}
 			else if ( cmdpage.endsWith( '/' ) ) {
 				if ( body.query.pages['-1'] ) {
-					wiki = new Wiki('https://minecraft.gamepedia.com/');
+					wiki = new Wiki('https://minecraft.fandom.com/');
 					cmdpage = 'Commands/';
 				}
 				else {
@@ -57,7 +57,7 @@ function minecraft_syntax(lang, msg, wiki, mccmd, args, title, cmd, reaction, sp
 						aliasCmd = mccmd;
 					}
 					else {
-						wiki = new Wiki('https://minecraft.gamepedia.com/');
+						wiki = new Wiki('https://minecraft.fandom.com/');
 						cmdpage = 'Commands/';
 					}
 				}

+ 108 - 42
cmds/patreon.js

@@ -55,60 +55,95 @@ function cmd_patreon(lang, msg, args, line, wiki) {
 		if ( !patreons[args[1]] ) return msg.replyMsg( '"' + guild + '" doesn\'t have the patreon features enabled.', {}, true );
 		return db.connect().then( client => {
 			return client.query( 'SELECT lang, role, inline FROM discord WHERE guild = $1 AND patreon = $2', [args[1], msg.author.id] ).then( ({rows:[row]}) => {
-				if ( !row ) return msg.replyMsg( 'you didn\'t enable the patreon features for "' + guild + '"!', {}, true );
-				if ( process.env.READONLY ) return msg.replyMsg( lang.get('general.readonly') + '\n' + process.env.invite, {}, true );
+				if ( !row ) {
+					msg.replyMsg( 'you didn\'t enable the patreon features for "' + guild + '"!', {}, true );
+					return Promise.reject();
+				}
+				if ( process.env.READONLY ) {
+					msg.replyMsg( lang.get('general.readonly') + '\n' + process.env.invite, {}, true );
+					return Promise.reject();
+				}
 				return client.query( 'UPDATE discord SET lang = $1, role = $2, inline = $3, prefix = $4, patreon = NULL WHERE guild = $5', [row.lang, row.role, row.inline, process.env.prefix, args[1]] ).then( () => {
 					console.log( '- Guild successfully updated.' );
 					msg.client.shard.broadcastEval( `delete global.patreons['${args[1]}']` );
 					msg.replyMsg( 'the patreon features are now disabled on "' + guild + '".', {}, true );
+				}, dberror => {
+					console.log( '- Error while updating the guild: ' + dberror );
+					msg.replyMsg( 'I got an error while searching for the server, please try again later.', {}, true );
+					return Promise.reject();
 				} ).then( () => {
-					return client.query( 'DELETE FROM discord WHERE guild = $1 AND channel LIKE $2', [args[1], '#%'] ).then( ({rowCount}) => {
-						if ( dberror ) {
-							console.log( '- Error while deleting the channel categories: ' + dberror );
-							return dberror;
-						}
-						if ( rowCount ) console.log( '- Channel categories successfully deleted.' );
-					} );
-				} ).then( () => {
-					return client.query( 'SELECT configid FROM verification WHERE guild = $1 ORDER BY configid ASC OFFSET $2', [args[1], verificationLimit.default] ).then( ({rows}) => {
-						if ( rows.length ) {
-							return client.query( 'DELETE FROM verification WHERE guild = $1 AND configid IN (' + rows.map( (row, i) => '$' + ( i + 2 ) ).join(', ') + ')', [args[1], ...rows.map( row => row.configid )] ).then( () => {
-								console.log( '- Verifications successfully deleted.' );
-							}, dberror => {
-								console.log( '- Error while deleting the verifications: ' + dberror );
-							} );
-						}
-					}, dberror => {
-						console.log( '- Error while getting the verifications: ' + dberror );
-					} );
-				} ).then( () => {
-					return client.query( 'SELECT webhook FROM rcgcdw WHERE guild = $1 ORDER BY configid ASC OFFSET $2', [args[1], rcgcdwLimit.default] ).then( ({rows}) => {
+					return client.query( 'DELETE FROM discord WHERE guild = $1 AND channel LIKE $2 RETURNING channel, wiki', [args[1], '#%'] ).then( ({rows}) => {
 						if ( rows.length ) {
-							return client.query( 'DELETE FROM rcgcdw WHERE webhook IN (' + rows.map( (row, i) => '$' + ( i + 1 ) ).join(', ') + ')', rows.map( row => row.webhook ) ).then( () => {
-								console.log( '- RcGcDw successfully deleted.' );
-								rows.forEach( row => msg.client.fetchWebhook(...row.webhook.split('/')).then( webhook => {
-									webhook.delete('Removed extra recent changes webhook').catch(log_error);
-								}, log_error ) );
-							}, dberror => {
-								console.log( '- Error while deleting the RcGcDw: ' + dberror );
+							console.log( '- Channel categories successfully deleted.' );
+							return msg.client.shard.broadcastEval( `if ( this.guilds.cache.has('${args[1]}') ) {
+								let rows = ${JSON.stringify(rows)};
+								this.guilds.cache.get('${args[1]}').channels.cache.filter( channel => {
+									return ( channel.isGuild() && rows.some( row => {
+										return ( row.channel === '#' + channel.parentID );
+									} ) );
+								} ).map( channel => {
+									return {
+										id: channel.id,
+										wiki: rows.find( row => {
+											return ( row.channel === '#' + channel.parentID );
+										} ).wiki
+									};
+								} )
+							}`, shardIDForGuildID(args[1], msg.client.shard.count) ).then( channels => {
+								if ( channels.length ) return Promise.all(channels.map( channel => {
+									return client.query( 'INSERT INTO discord(wiki, guild, channel, lang, role, inline, prefix) VALUES($1, $2, $3, $4, $5, $6, $7)', [channel.wiki, args[1], channel.id, row.lang, row.role, row.inline, process.env.prefix] ).catch( dberror => {
+										if ( dberror.message !== 'duplicate key value violates unique constraint "discord_guild_channel_key"' ) {
+											console.log( '- Error while adding category settings to channels: ' + dberror );
+										}
+									} );
+								} ));
+							}, error => {
+								console.log( '- Error while getting the channels in categories: ' + error );
 							} );
 						}
 					}, dberror => {
-						console.log( '- Error while getting the RcGcDw: ' + dberror );
-					} );
-				} ).then( () => {
-					return client.query( 'UPDATE rcgcdw SET display = $1 WHERE guild = $2 AND display > $1', [rcgcdwLimit.display, args[1]] ).then( () => {
-						console.log( '- RcGcDw successfully updated.' );
-					}, dberror => {
-						console.log( '- Error while updating the RcGcDw: ' + dberror );
+						console.log( '- Error while deleting the channel categories: ' + dberror );
 					} );
-				}, dberror => {
-					console.log( '- Error while updating the guild: ' + dberror );
-					msg.replyMsg( 'I got an error while updating the server, please try again later.', {}, true );
 				} );
 			}, dberror => {
 				console.log( '- Error while getting the guild: ' + dberror );
 				msg.replyMsg( 'I got an error while searching for the server, please try again later.', {}, true );
+				return Promise.reject();
+			} ).then( () => {
+				return client.query( 'SELECT configid FROM verification WHERE guild = $1 ORDER BY configid ASC OFFSET $2', [args[1], verificationLimit.default] ).then( ({rows}) => {
+					if ( rows.length ) {
+						return client.query( 'DELETE FROM verification WHERE guild = $1 AND configid IN (' + rows.map( (row, i) => '$' + ( i + 2 ) ).join(', ') + ')', [args[1], ...rows.map( row => row.configid )] ).then( () => {
+							console.log( '- Verifications successfully deleted.' );
+						}, dberror => {
+							console.log( '- Error while deleting the verifications: ' + dberror );
+						} );
+					}
+				}, dberror => {
+					console.log( '- Error while getting the verifications: ' + dberror );
+				} );
+			} ).then( () => {
+				return client.query( 'SELECT webhook FROM rcgcdw WHERE guild = $1 ORDER BY configid ASC OFFSET $2', [args[1], rcgcdwLimit.default] ).then( ({rows}) => {
+					if ( rows.length ) {
+						return client.query( 'DELETE FROM rcgcdw WHERE webhook IN (' + rows.map( (row, i) => '$' + ( i + 1 ) ).join(', ') + ')', rows.map( row => row.webhook ) ).then( () => {
+							console.log( '- RcGcDw successfully deleted.' );
+							rows.forEach( row => msg.client.fetchWebhook(...row.webhook.split('/')).then( webhook => {
+								webhook.delete('Removed extra recent changes webhook').catch(log_error);
+							}, log_error ) );
+						}, dberror => {
+							console.log( '- Error while deleting the RcGcDw: ' + dberror );
+						} );
+					}
+				}, dberror => {
+					console.log( '- Error while getting the RcGcDw: ' + dberror );
+				} );
+			} ).then( () => {
+				return client.query( 'UPDATE rcgcdw SET display = $1 WHERE guild = $2 AND display > $1', [rcgcdwLimit.display, args[1]] ).then( () => {
+					console.log( '- RcGcDw successfully updated.' );
+				}, dberror => {
+					console.log( '- Error while updating the RcGcDw: ' + dberror );
+				} );
+			} ).catch( error => {
+				if ( error ) console.log( '- Error while removing the patreon features: ' + error );
 			} ).finally( () => {
 				client.release();
 			} );
@@ -191,8 +226,39 @@ function cmd_patreon(lang, msg, args, line, wiki) {
 					console.log( '- Error while getting the guilds: ' + dberror );
 				} );
 			} ).then( () => {
-				return client.query( 'DELETE FROM discord WHERE guild IN (' + guilds.map( (guild, i) => '$' + ( i + 2 ) ).join(', ') + ') AND channel LIKE $1', ['#%', ...guilds] ).then( ({rowCount}) => {
-					if ( rowCount ) console.log( '- Channel categories successfully deleted.' );
+				return client.query( 'DELETE FROM discord WHERE guild IN (' + guilds.map( (guild, i) => '$' + ( i + 2 ) ).join(', ') + ') AND channel LIKE $1 RETURNING wiki, guild, channel, lang, role, inline', ['#%', ...guilds] ).then( ({rows}) => {
+					if ( rows.length ) {
+						console.log( '- Channel categories successfully deleted.' );
+						return msg.client.shard.broadcastEval( `let rows = ${JSON.stringify(rows)};
+						[].concat(...${JSON.stringify(guilds)}.filter( guild => {
+							return this.guilds.cache.has(guild);
+						} ).map( guild => {
+							return this.guilds.cache.get(guild).channels.cache.filter( channel => {
+								return ( channel.isGuild() && rows.some( row => {
+									return ( row.channel === '#' + channel.parentID );
+								} ) );
+							} ).map( channel => {
+								let row = rows.find( row => {
+									return ( row.channel === '#' + channel.parentID );
+								} );
+								return {
+									id: channel.id, guild: row.guild, wiki: row.wiki,
+									lang: row.lang, role: row.role, inline: row.inline
+								};
+							} );
+						} ))` ).then( response => {
+							var channels = [].concat(...response);
+							if ( channels.length ) return Promise.all(channels.map( channel => {
+								return client.query( 'INSERT INTO discord(wiki, guild, channel, lang, role, inline, prefix) VALUES($1, $2, $3, $4, $5, $6, $7)', [channel.wiki, channel.guild, channel.id, channel.lang, channel.role, channel.inline, process.env.prefix] ).catch( dberror => {
+									if ( dberror.message !== 'duplicate key value violates unique constraint "discord_guild_channel_key"' ) {
+										console.log( '- Error while adding category settings to channels: ' + dberror );
+									}
+								} );
+							} ));
+						}, error => {
+							console.log( '- Error while getting the channels in categories: ' + error );
+						} );
+					}
 				}, dberror => {
 					console.log( '- Error while deleting the channel categories: ' + dberror );
 				} );

+ 1 - 1
functions/global_block.js

@@ -49,7 +49,7 @@ function global_block(lang, msg, username, text, embed, wiki, spoiler, gender) {
 		}, error => {
 			console.log( '- Error while getting the global block: ' + error );
 		} ),
-		( isUser && wiki.isGamepedia() ? got.get( 'https://help.gamepedia.com/UserProfile:' + encodeURIComponent( username ) + '?cache=' + Date.now(), {
+		( isUser && wiki.isGamepedia() ? got.get( 'https://help.fandom.com/wiki/UserProfile:' + encodeURIComponent( username ) + '?cache=' + Date.now(), {
 			responseType: 'text'
 		} ).then( gresponse => {
 			var gbody = gresponse.body;

+ 5 - 5
i18n/en.json

@@ -146,7 +146,7 @@
     "general": {
         "database": "⚠️ **Limited Functionality** ⚠️\nNo settings found, please contact the bot owner!",
         "default": "this server isn't set up yet. Use $1 or the dashboard to change the settings.",
-        "disclaimer": "I am a small bot with the purpose to easily link and search MediaWiki sites like Gamepedia and Fandom wikis. I show short descriptions and additional info about pages and am able to resolve redirects and follow interwiki links. $1 wrote me in JavaScript.\n\nYou can support me on Patreon:",
+        "disclaimer": "I am a small bot with the purpose to easily link and search MediaWiki sites like Wikipedia and Fandom wikis. I show short descriptions and additional info about pages and am able to resolve redirects and follow interwiki links. $1 wrote me in JavaScript.\n\nYou can support me on Patreon:",
         "experimental": "**This feature is experimental! It is not guaranteed to work correctly and may be removed in the future.**",
         "helpserver": "For questions and problems please visit my support server:",
         "limit": "🚨 **Stop, you hit a limit!** 🚨\n\n$1, your message contained too many commands!",
@@ -516,7 +516,7 @@
         "help_display_image": "Embed messages with image previews.",
         "help_feeds": "(discussions, message walls, article comments)",
         "help_lang": "Currently supported languages are:",
-        "help_wiki": "Link to a MediaWiki site like `https://<wiki>.gamepedia.com/` or `https://<wiki>.fandom.com/`",
+        "help_wiki": "Link to a MediaWiki site like `https://<wiki>.fandom.com/`",
         "lang": "Language:",
         "max_entries": "you already reached the maximal amount of recent changes webhooks.",
         "missing": "there are no recent changes webhooks for this server yet.",
@@ -633,8 +633,8 @@
         "save_failed": "sadly the settings couldn't be saved, please try again later.",
         "wiki": "the default wiki for this server is:",
         "wikichanged": "you changed the default wiki for this server to:",
-        "wikihelp": "Use `$1 <link>` to change the default wiki.\nLink to a MediaWiki site like `https://<wiki>.gamepedia.com/` or `https://<wiki>.fandom.com/`",
-        "wikiinvalid": "please provide a valid link to a MediaWiki site, like a Gamepedia or Fandom wiki!",
+        "wikihelp": "Use `$1 <link>` to change the default wiki.\nLink to a MediaWiki site like `https://<wiki>.fandom.com/`",
+        "wikiinvalid": "please provide a valid link to a MediaWiki site, like a Wikipedia or Fandom wiki!",
         "wikiinvalid_http": "the provided website doesn't have a valid TLS/SSL certificate! For security reasons only wikis using HTTPS are supported.\nIf you are a site administrator, you can get a certificate from a certificate authority like *Let’s Encrypt*:\n<https://letsencrypt.org/getting-started/>",
         "wikiinvalid_private": "the provided wiki is private! Only public wikis that can be read by everyone are supported.",
         "wikiinvalid_timeout": "the provided link took too long to respond!",
@@ -771,7 +771,7 @@
         "failed_roles": "**Adding roles failed!**",
         "footer": "Wiki Account Verification",
         "help_fandom": "https://community.fandom.com/wiki/Special:VerifyUser",
-        "help_gamepedia": "https://help.gamepedia.com/Gamepedia_Help_Wiki:Discord_verification",
+        "help_gamepedia": "https://help.fandom.com/wiki/Gamepedia_Help_Wiki:Discord_verification",
         "help_guide": "Follow [this guide]($1) to add your Discord tag to your wiki profile:",
         "help_subpage": "Please add your Discord tag ($1) to your Discord subpage on the wiki:",
         "missing": "there are no verifications set up for this channel.",

+ 2 - 12
interactions/inline.js

@@ -12,7 +12,7 @@ const {limitLength, partialURIdecode, allowDelete} = require('../util/functions.
 function slash_inline(interaction, lang, wiki, channel) {
 	var text = ( interaction.data.options?.[0]?.value || '' ).replace( /\]\(/g, ']\\(' );
 	text = text.replace( /\x1F/g, '' ).replace( /(?<!@)\u200b/g, '' ).trim();
-	if ( !text ) {
+	if ( !text.includes( '{{' ) && !( text.includes( '[[' ) && text.includes( ']]' ) ) && !text.includes( 'PMID' ) && !text.includes( 'RFC' ) && !text.includes( 'ISBN' ) ) {
 		return got.post( `https://discord.com/api/v8/interactions/${interaction.id}/${interaction.token}/callback`, {
 			json: {
 				type: 4,
@@ -63,15 +63,8 @@ function slash_inline(interaction, lang, wiki, channel) {
 	};
 	return got.post( `https://discord.com/api/v8/interactions/${interaction.id}/${interaction.token}/callback`, {
 		json: {
-			type: 4,
+			type: 5,
 			data: {
-				content: text.replace( /(?<!\\)<a?(:\w+:)\d+>/g, (replacement, emoji, id) => {
-					if ( channel?.guild?.emojis.cache.has(id) ) {
-						return replacement;
-					}
-					return emoji;
-				} ),
-				allowed_mentions,
 				flags: 0
 			}
 		}
@@ -80,9 +73,6 @@ function slash_inline(interaction, lang, wiki, channel) {
 			console.log( '- Slash: ' + aresponse.statusCode + ': Error while sending the response: ' + aresponse.body?.message );
 			return;
 		}
-		if ( !text.includes( '{{' ) && !( text.includes( '[[' ) && text.includes( ']]' ) ) && !text.includes( 'PMID' ) && !text.includes( 'RFC' ) && !text.includes( 'ISBN' ) ) {
-			return sendMessage(interaction, message, channel);
-		}
 		var textReplacement = [];
 		var magiclinks = [];
 		var replacedText = text.replace( /(?<!\\)(?:<a?(:\w+:)\d+>|<#(\d+)>|<@!?(\d+)>|<@&(\d+)>|```.+?```|``.+?``|`.+?`)/gs, (replacement, emoji, textchannel, user, role) => {

+ 1 - 1
util/functions.js

@@ -336,7 +336,7 @@ function htmlToDiscord(html, pagelink = '', ...escapeArgs) {
 			}
 		},
 		oncomment: (commenttext) => {
-			if ( pagelink && /^LINK'" \d+:\d+$/.test(commenttext) ) {
+			if ( pagelink && /^(?:IW)?LINK'" \d+:\d+$/.test(commenttext) ) {
 				text += '*UNKNOWN LINK*';
 			}
 		}