Browse Source

Rename Gamepedia files to general

Markus-Rost 4 years ago
parent
commit
e36c3d39f5

+ 3 - 3
cmds/link.js

@@ -1,6 +1,6 @@
 const check_wiki = {
 const check_wiki = {
-	fandom: require('./wiki/fandom.js'),
-	gamepedia: require('./wiki/gamepedia.js'),
+	fandom: require('./wiki/fandom/general.js'),
+	general: require('./wiki/general.js'),
 	test: require('./test.js').run
 	test: require('./test.js').run
 };
 };
 const help_setup = require('../functions/helpsetup.js');
 const help_setup = require('../functions/helpsetup.js');
@@ -20,7 +20,7 @@ function cmd_link(lang, msg, title, wiki, cmd = '') {
 		var spoiler = '||';
 		var spoiler = '||';
 	}
 	}
 	msg.reactEmoji('⏳').then( reaction => {
 	msg.reactEmoji('⏳').then( reaction => {
-		check_wiki.gamepedia(lang, msg, title, wiki, cmd, reaction, spoiler);
+		check_wiki.general(lang, msg, title, wiki, cmd, reaction, spoiler);
 	} );
 	} );
 }
 }
 
 

+ 1 - 1
cmds/minecraft/bug.js

@@ -124,7 +124,7 @@ function minecraft_bug(lang, msg, args, title, cmd, querystring, fragment, react
 	}
 	}
 	else {
 	else {
 		msg.notMinecraft = true;
 		msg.notMinecraft = true;
-		this.WIKI.gamepedia(lang, msg, title, new Wiki(lang.get('minecraft.link')), cmd, reaction, spoiler, querystring, fragment);
+		this.WIKI.general(lang, msg, title, new Wiki(lang.get('minecraft.link')), cmd, reaction, spoiler, querystring, fragment);
 	}
 	}
 }
 }
 
 

+ 1 - 1
cmds/minecraft/command.js

@@ -19,7 +19,7 @@ function minecraft_command(lang, msg, args, title, cmd, querystring, fragment, r
 	}
 	}
 	else {
 	else {
 		msg.notMinecraft = true;
 		msg.notMinecraft = true;
-		this.WIKI.gamepedia(lang, msg, title, new Wiki(lang.get('minecraft.link')), cmd, reaction, spoiler, querystring, fragment);
+		this.WIKI.general(lang, msg, title, new Wiki(lang.get('minecraft.link')), cmd, reaction, spoiler, querystring, fragment);
 	}
 	}
 }
 }
 
 

+ 1 - 1
cmds/minecraft/syntax.js

@@ -41,7 +41,7 @@ function minecraft_syntax(lang, msg, mccmd, args, title, cmd, querystring, fragm
 	else {
 	else {
 		msg.reactEmoji('❓');
 		msg.reactEmoji('❓');
 		msg.notMinecraft = true;
 		msg.notMinecraft = true;
-		this.WIKI.gamepedia(lang, msg, title, new Wiki(lang.get('minecraft.link')), cmd, reaction, spoiler, querystring, fragment);
+		this.WIKI.general(lang, msg, title, new Wiki(lang.get('minecraft.link')), cmd, reaction, spoiler, querystring, fragment);
 	}
 	}
 }
 }
 
 

+ 7 - 7
cmds/wiki/gamepedia/diff.js → cmds/wiki/diff.js

@@ -1,14 +1,14 @@
 const {MessageEmbed} = require('discord.js');
 const {MessageEmbed} = require('discord.js');
-const {timeoptions} = require('../../../util/default.json');
-const {toFormatting, htmlToPlain} = require('../../../util/functions.js');
-const diffParser = require('../../../util/edit_diff.js');
+const {timeoptions} = require('../../util/default.json');
+const {toFormatting, htmlToPlain} = require('../../util/functions.js');
+const diffParser = require('../../util/edit_diff.js');
 
 
 /**
 /**
  * Processes a Gamepedia edit.
  * Processes a Gamepedia edit.
- * @param {import('../../../util/i18n.js')} lang - The user language.
+ * @param {import('../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {String[]} args - The command arguments.
  * @param {String[]} args - The command arguments.
- * @param {import('../../../util/wiki.js')} wiki - The wiki for the edit.
+ * @param {import('../../util/wiki.js')} wiki - The wiki for the edit.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {MessageEmbed} [embed] - The embed for the page.
  * @param {MessageEmbed} [embed] - The embed for the page.
@@ -137,10 +137,10 @@ function gamepedia_diff(lang, msg, args, wiki, reaction, spoiler, embed) {
 
 
 /**
 /**
  * Sends a Gamepedia edit.
  * Sends a Gamepedia edit.
- * @param {import('../../../util/i18n.js')} lang - The user language.
+ * @param {import('../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {String[]} args - The command arguments.
  * @param {String[]} args - The command arguments.
- * @param {import('../../../util/wiki.js')} wiki - The wiki for the edit.
+ * @param {import('../../util/wiki.js')} wiki - The wiki for the edit.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String[]} [compare] - The edit difference.
  * @param {String[]} [compare] - The edit difference.

+ 10 - 10
cmds/wiki/fandom.js → cmds/wiki/fandom/general.js

@@ -1,24 +1,24 @@
 const htmlparser = require('htmlparser2');
 const htmlparser = require('htmlparser2');
 const {MessageEmbed} = require('discord.js');
 const {MessageEmbed} = require('discord.js');
-const {limit: {interwiki: interwikiLimit}, wikiProjects} = require('../../util/default.json');
-const Wiki = require('../../util/wiki.js');
+const {limit: {interwiki: interwikiLimit}, wikiProjects} = require('../../../util/default.json');
+const Wiki = require('../../../util/wiki.js');
 
 
 const fs = require('fs');
 const fs = require('fs');
 var fn = {
 var fn = {
-	special_page: require('../../functions/special_page.js'),
-	discussion: require('../../functions/discussion.js')
+	special_page: require('../../../functions/special_page.js'),
+	discussion: require('../../../functions/discussion.js')
 };
 };
 fs.readdir( './cmds/wiki/fandom', (error, files) => {
 fs.readdir( './cmds/wiki/fandom', (error, files) => {
 	if ( error ) return error;
 	if ( error ) return error;
-	files.filter( file => file.endsWith('.js') ).forEach( file => {
-		var command = require('./fandom/' + file);
+	files.filter( file => ( file !== 'general.js' && file.endsWith('.js') ) ).forEach( file => {
+		var command = require('./' + file);
 		fn[command.name] = command.run;
 		fn[command.name] = command.run;
 	} );
 	} );
 } );
 } );
 
 
 /**
 /**
  * Checks a Fandom wiki.
  * Checks a Fandom wiki.
- * @param {import('../../util/i18n.js')} lang - The user language.
+ * @param {import('../../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {String} title - The page title.
  * @param {String} title - The page title.
  * @param {Wiki} wiki - The wiki for the page.
  * @param {Wiki} wiki - The wiki for the page.
@@ -422,13 +422,13 @@ function fandom_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '',
 						let path = ( regex[1] || '' );
 						let path = ( regex[1] || '' );
 						let iwtitle = decodeURIComponent( iw.pathname.replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						let iwtitle = decodeURIComponent( iw.pathname.replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						cmd = ( iw.hostname.endsWith( '.wikia.org' ) ? '??' : '?' ) + ( path ? path.substring(1) + '.' : '' ) + iw.hostname.replace( /\.(?:fandom\.com|wikia\.org)/, ' ' );
 						cmd = ( iw.hostname.endsWith( '.wikia.org' ) ? '??' : '?' ) + ( path ? path.substring(1) + '.' : '' ) + iw.hostname.replace( /\.(?:fandom\.com|wikia\.org)/, ' ' );
-						return this.gamepedia(lang, msg, iwtitle, new Wiki(iw.origin + path + '/'), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+						return this.general(lang, msg, iwtitle, new Wiki(iw.origin + path + '/'), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 					}
 					}
 				}
 				}
 				if ( iw.hostname.endsWith( '.gamepedia.com' ) ) {
 				if ( iw.hostname.endsWith( '.gamepedia.com' ) ) {
 					let iwtitle = decodeURIComponent( iw.pathname.substring(1) ).replace( /_/g, ' ' );
 					let iwtitle = decodeURIComponent( iw.pathname.substring(1) ).replace( /_/g, ' ' );
 					cmd = '!' + iw.hostname.replace( '.gamepedia.com', ' ' );
 					cmd = '!' + iw.hostname.replace( '.gamepedia.com', ' ' );
-					if ( cmd !== '!www ' ) return this.gamepedia(lang, msg, iwtitle, new Wiki(iw.origin), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+					if ( cmd !== '!www ' ) return this.general(lang, msg, iwtitle, new Wiki(iw.origin), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 				}
 				}
 				let project = wikiProjects.find( project => iw.hostname.endsWith( project.name ) );
 				let project = wikiProjects.find( project => iw.hostname.endsWith( project.name ) );
 				if ( project ) {
 				if ( project ) {
@@ -436,7 +436,7 @@ function fandom_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '',
 					if ( regex ) {
 					if ( regex ) {
 						let iwtitle = decodeURIComponent( ( iw.host + iw.pathname ).replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						let iwtitle = decodeURIComponent( ( iw.host + iw.pathname ).replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						cmd = '!!' + regex[1] + ' ';
 						cmd = '!!' + regex[1] + ' ';
-						return this.gamepedia(lang, msg, iwtitle, new Wiki('https://' + regex[1] + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+						return this.general(lang, msg, iwtitle, new Wiki('https://' + regex[1] + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 					}
 					}
 				}
 				}
 			}
 			}

+ 6 - 6
cmds/wiki/gamepedia.js → cmds/wiki/general.js

@@ -10,10 +10,10 @@ var fn = {
 	special_page: require('../../functions/special_page.js'),
 	special_page: require('../../functions/special_page.js'),
 	discussion: require('../../functions/discussion.js')
 	discussion: require('../../functions/discussion.js')
 };
 };
-fs.readdir( './cmds/wiki/gamepedia', (error, files) => {
+fs.readdir( './cmds/wiki', (error, files) => {
 	if ( error ) return error;
 	if ( error ) return error;
-	files.filter( file => file.endsWith('.js') ).forEach( file => {
-		var command = require('./gamepedia/' + file);
+	files.filter( file => ( file !== 'general.js' && file.endsWith('.js') ) ).forEach( file => {
+		var command = require('./' + file);
 		fn[command.name] = command.run;
 		fn[command.name] = command.run;
 	} );
 	} );
 } );
 } );
@@ -347,7 +347,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 				if ( iw.hostname.endsWith( '.gamepedia.com' ) ) {
 				if ( iw.hostname.endsWith( '.gamepedia.com' ) ) {
 					let iwtitle = decodeURIComponent( iw.pathname.substring(1) ).replace( /_/g, ' ' );
 					let iwtitle = decodeURIComponent( iw.pathname.substring(1) ).replace( /_/g, ' ' );
 					cmd = '!' + iw.hostname.replace( '.gamepedia.com', ' ' );
 					cmd = '!' + iw.hostname.replace( '.gamepedia.com', ' ' );
-					if ( cmd !== '!www ' ) return this.gamepedia(lang, msg, iwtitle, new Wiki(iw.origin), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+					if ( cmd !== '!www ' ) return this.general(lang, msg, iwtitle, new Wiki(iw.origin), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 				}
 				}
 				if ( iw.hostname.endsWith( '.fandom.com' ) || iw.hostname.endsWith( '.wikia.org' ) ) {
 				if ( iw.hostname.endsWith( '.fandom.com' ) || iw.hostname.endsWith( '.wikia.org' ) ) {
 					let regex = iw.pathname.match( /^(\/(?!wiki\/)[a-z-]{2,12})?(?:\/wiki\/|\/?$)/ );
 					let regex = iw.pathname.match( /^(\/(?!wiki\/)[a-z-]{2,12})?(?:\/wiki\/|\/?$)/ );
@@ -355,7 +355,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 						let path = ( regex[1] || '' );
 						let path = ( regex[1] || '' );
 						let iwtitle = decodeURIComponent( iw.pathname.replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						let iwtitle = decodeURIComponent( iw.pathname.replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						cmd = ( iw.hostname.endsWith( '.wikia.org' ) ? '??' : '?' ) + ( path ? path.substring(1) + '.' : '' ) + iw.hostname.replace( /\.(?:fandom\.com|wikia\.org)/, ' ' );
 						cmd = ( iw.hostname.endsWith( '.wikia.org' ) ? '??' : '?' ) + ( path ? path.substring(1) + '.' : '' ) + iw.hostname.replace( /\.(?:fandom\.com|wikia\.org)/, ' ' );
-						return this.gamepedia(lang, msg, iwtitle, new Wiki(iw.origin + path + '/'), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+						return this.general(lang, msg, iwtitle, new Wiki(iw.origin + path + '/'), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 					}
 					}
 				}
 				}
 				let project = wikiProjects.find( project => iw.hostname.endsWith( project.name ) );
 				let project = wikiProjects.find( project => iw.hostname.endsWith( project.name ) );
@@ -364,7 +364,7 @@ function gamepedia_check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '
 					if ( regex ) {
 					if ( regex ) {
 						let iwtitle = decodeURIComponent( ( iw.host + iw.pathname ).replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						let iwtitle = decodeURIComponent( ( iw.host + iw.pathname ).replace( regex[0], '' ) ).replace( /_/g, ' ' );
 						cmd = '!!' + regex[1] + ' ';
 						cmd = '!!' + regex[1] + ' ';
-						return this.gamepedia(lang, msg, iwtitle, new Wiki('https://' + regex[1] + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
+						return this.general(lang, msg, iwtitle, new Wiki('https://' + regex[1] + project.scriptPath), cmd, reaction, spoiler, iw.searchParams, fragment, iw.href, selfcall);
 					}
 					}
 				}
 				}
 			}
 			}

+ 5 - 5
cmds/wiki/gamepedia/overview.js → cmds/wiki/overview.js

@@ -1,16 +1,16 @@
 const {MessageEmbed} = require('discord.js');
 const {MessageEmbed} = require('discord.js');
-const fandom_overview = require('../fandom/overview.js').run;
-const {timeoptions} = require('../../../util/default.json');
+const fandom_overview = require('./fandom/overview.js').run;
+const {timeoptions} = require('../../util/default.json');
 
 
 var allSites = [];
 var allSites = [];
-const getAllSites = require('../../../util/allSites.js');
+const getAllSites = require('../../util/allSites.js');
 getAllSites.then( sites => allSites = sites );
 getAllSites.then( sites => allSites = sites );
 
 
 /**
 /**
  * Sends a Gamepedia wiki overview.
  * Sends a Gamepedia wiki overview.
- * @param {import('../../../util/i18n.js')} lang - The user language.
+ * @param {import('../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
- * @param {import('../../../util/wiki.js')} wiki - The wiki for the overview.
+ * @param {import('../../util/wiki.js')} wiki - The wiki for the overview.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String} spoiler - If the response is in a spoiler.
  */
  */

+ 6 - 6
cmds/wiki/gamepedia/random.js → cmds/wiki/random.js

@@ -1,14 +1,14 @@
 const {MessageEmbed} = require('discord.js');
 const {MessageEmbed} = require('discord.js');
-const fandom_random = require('../fandom/random.js').run;
-const parse_page = require('../../../functions/parse_page.js');
-const {htmlToPlain, htmlToDiscord} = require('../../../util/functions.js');
-const extract_desc = require('../../../util/extract_desc.js');
+const fandom_random = require('./fandom/random.js').run;
+const parse_page = require('../../functions/parse_page.js');
+const {htmlToPlain, htmlToDiscord} = require('../../util/functions.js');
+const extract_desc = require('../../util/extract_desc.js');
 
 
 /**
 /**
  * Sends a random Gamepedia page.
  * Sends a random Gamepedia page.
- * @param {import('../../../util/i18n.js')} lang - The user language.
+ * @param {import('../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
- * @param {import('../../../util/wiki.js')} wiki - The wiki for the page.
+ * @param {import('../../util/wiki.js')} wiki - The wiki for the page.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String} spoiler - If the response is in a spoiler.
  */
  */

+ 2 - 2
cmds/wiki/gamepedia/search.js → cmds/wiki/search.js

@@ -2,10 +2,10 @@ const {MessageEmbed, Util} = require('discord.js');
 
 
 /**
 /**
  * Searches a Gamepedia wiki.
  * Searches a Gamepedia wiki.
- * @param {import('../../../util/i18n.js')} lang - The user language.
+ * @param {import('../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {String} searchterm - The searchterm.
  * @param {String} searchterm - The searchterm.
- * @param {import('../../../util/wiki.js')} wiki - The wiki for the search.
+ * @param {import('../../util/wiki.js')} wiki - The wiki for the search.
  * @param {Object} query - The siteinfo from the wiki.
  * @param {Object} query - The siteinfo from the wiki.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {import('discord.js').MessageReaction} reaction - The reaction on the message.
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String} spoiler - If the response is in a spoiler.

+ 8 - 8
cmds/wiki/gamepedia/user.js → cmds/wiki/user.js

@@ -1,21 +1,21 @@
 const {MessageEmbed} = require('discord.js');
 const {MessageEmbed} = require('discord.js');
-const global_block = require('../../../functions/global_block.js');
-const parse_page = require('../../../functions/parse_page.js');
-const extract_desc = require('../../../util/extract_desc.js');
-const {timeoptions, usergroups} = require('../../../util/default.json');
-const {toMarkdown, toPlaintext, htmlToPlain, htmlToDiscord} = require('../../../util/functions.js');
+const global_block = require('../../functions/global_block.js');
+const parse_page = require('../../functions/parse_page.js');
+const extract_desc = require('../../util/extract_desc.js');
+const {timeoptions, usergroups} = require('../../util/default.json');
+const {toMarkdown, toPlaintext, htmlToPlain, htmlToDiscord} = require('../../util/functions.js');
 
 
 var allSites = [];
 var allSites = [];
-const getAllSites = require('../../../util/allSites.js');
+const getAllSites = require('../../util/allSites.js');
 getAllSites.then( sites => allSites = sites );
 getAllSites.then( sites => allSites = sites );
 
 
 /**
 /**
  * Processes a Gamepedia user.
  * Processes a Gamepedia user.
- * @param {import('../../../util/i18n.js')} lang - The user language.
+ * @param {import('../../util/i18n.js')} lang - The user language.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {import('discord.js').Message} msg - The Discord message.
  * @param {String} namespace - The user namespace on the wiki.
  * @param {String} namespace - The user namespace on the wiki.
  * @param {String} username - The name of the user.
  * @param {String} username - The name of the user.
- * @param {import('../../../util/wiki.js')} wiki - The wiki for the page.
+ * @param {import('../../util/wiki.js')} wiki - The wiki for the page.
  * @param {URLSearchParams} querystring - The querystring for the link.
  * @param {URLSearchParams} querystring - The querystring for the link.
  * @param {String} fragment - The section for the link.
  * @param {String} fragment - The section for the link.
  * @param {Object} querypage - The user page on the wiki.
  * @param {Object} querypage - The user page on the wiki.

+ 3 - 3
util/newMessage.js

@@ -2,8 +2,8 @@ const {Util} = require('discord.js');
 const {limit: {command: commandLimit}, defaultSettings, wikiProjects} = require('./default.json');
 const {limit: {command: commandLimit}, defaultSettings, wikiProjects} = require('./default.json');
 const Wiki = require('./wiki.js');
 const Wiki = require('./wiki.js');
 const check_wiki = {
 const check_wiki = {
-	fandom: require('../cmds/wiki/fandom.js'),
-	gamepedia: require('../cmds/wiki/gamepedia.js'),
+	fandom: require('../cmds/wiki/fandom/general.js'),
+	general: require('../cmds/wiki/general.js'),
 	test: require('../cmds/test.js').run
 	test: require('../cmds/test.js').run
 };
 };
 
 
@@ -226,7 +226,7 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 				}
 				}
 			}
 			}
 			if ( embeds.length ) embeds.forEach( embed => msg.reactEmoji('⏳').then( reaction => {
 			if ( embeds.length ) embeds.forEach( embed => msg.reactEmoji('⏳').then( reaction => {
-				check_wiki.gamepedia(lang, msg, embed.title, wiki, '', reaction, embed.spoiler, new URLSearchParams(), embed.section);
+				check_wiki.general(lang, msg, embed.title, wiki, '', reaction, embed.spoiler, new URLSearchParams(), embed.section);
 			} ) );
 			} ) );
 		}, error => {
 		}, error => {
 			if ( wiki.noWiki(error.message) ) {
 			if ( wiki.noWiki(error.message) ) {