Browse Source

fix allsites

Markus-Rost 4 năm trước cách đây
mục cha
commit
a87fd36835
2 tập tin đã thay đổi với 3 bổ sung3 xóa
  1. 1 1
      cmds/wiki/fandom/overview.js
  2. 2 2
      util/allSites.js

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

@@ -16,7 +16,7 @@ getAllSites.then( sites => allSites = sites );
  * @param {String} spoiler - If the response is in a spoiler.
  * @param {String} spoiler - If the response is in a spoiler.
  */
  */
 function fandom_overview(lang, msg, wiki, reaction, spoiler) {
 function fandom_overview(lang, msg, wiki, reaction, spoiler) {
-	if ( !allSites.length ) getAllSites.get().then( sites => allSites = sites );
+	if ( !allSites.length ) getAllSites.update();
 	got.get( wiki + 'api.php?action=query&meta=allmessages|siteinfo&ammessages=custom-Wiki_Manager|custom-GamepediaNotice|custom-FandomMergeNotice&amenableparser=true&siprop=general|statistics|wikidesc&titles=Special:Statistics&format=json' ).then( response => {
 	got.get( wiki + 'api.php?action=query&meta=allmessages|siteinfo&ammessages=custom-Wiki_Manager|custom-GamepediaNotice|custom-FandomMergeNotice&amenableparser=true&siprop=general|statistics|wikidesc&titles=Special:Statistics&format=json' ).then( response => {
 		var body = response.body;
 		var body = response.body;
 		if ( body && body.warnings ) log_warn(body.warnings);
 		if ( body && body.warnings ) log_warn(body.warnings);

+ 2 - 2
util/allSites.js

@@ -5,7 +5,7 @@ var allSites = getAllSites();
  * @returns {Promise<Object[]>}
  * @returns {Promise<Object[]>}
  */
  */
 function getAllSites() {
 function getAllSites() {
-	return got.get( 'https://help.gamepedia.com/api.php?action=allsites&formatversion=2&do=getSiteStats&filter=wikis|md5_key,wiki_domain,wiki_display_name,wiki_image,wiki_description,wiki_managers,official_wiki,wiki_crossover,created&format=json' ).then( response => {
+	return got.get( 'https://wikisandbox.gamepedia.com/api.php?action=allsites&formatversion=2&do=getSiteStats&filter=wikis|md5_key,wiki_domain,wiki_display_name,wiki_image,wiki_description,wiki_managers,official_wiki,wiki_crossover,created&format=json' ).then( response => {
 		var body = response.body;
 		var body = response.body;
 		if ( response.statusCode !== 200 || !body || body.status !== 'okay' || !body.data || !body.data.wikis ) {
 		if ( response.statusCode !== 200 || !body || body.status !== 'okay' || !body.data || !body.data.wikis ) {
 			console.log( '- ' + shardId + ': ' + response.statusCode + ': Error while gettings all sites: ' + ( body && body.error && body.error.info ) );
 			console.log( '- ' + shardId + ': ' + response.statusCode + ': Error while gettings all sites: ' + ( body && body.error && body.error.info ) );
@@ -29,7 +29,7 @@ function getAllSites() {
  */
  */
 function updateAllSites() {
 function updateAllSites() {
 	return new Promise( function(resolve, reject) {
 	return new Promise( function(resolve, reject) {
-		getAllSites.then( newSites => {
+		getAllSites().then( newSites => {
 			if ( newSites.length ) allSites.then( sites => {
 			if ( newSites.length ) allSites.then( sites => {
 				sites.splice(0, sites.length);
 				sites.splice(0, sites.length);
 				sites.push(...newSites);
 				sites.push(...newSites);