Browse Source

fix Gamepedia overview and linline embeds

Markus-Rost 4 years ago
parent
commit
8d900421b6
6 changed files with 20 additions and 14 deletions
  1. 4 4
      bot.js
  2. 4 0
      cmds/eval.js
  3. 3 3
      cmds/wiki/gamepedia/overview.js
  4. 4 3
      dashboard/index.js
  5. 3 2
      main.js
  6. 2 2
      util/newMessage.js

+ 4 - 4
bot.js

@@ -344,13 +344,13 @@ global.log_warn = function(warning, api = true) {
  * End the process gracefully.
  * @param {NodeJS.Signals} signal - The signal received.
  */
-async function graceful(signal) {
+function graceful(signal) {
 	isStop = true;
 	console.log( '- ' + shardId + ': ' + signal + ': Preparing to close...' );
-	setTimeout( async () => {
+	setTimeout( () => {
 		console.log( '- ' + shardId + ': ' + signal + ': Destroying client...' );
-		await client.destroy();
-		await db.close( dberror => {
+		client.destroy();
+		db.close( dberror => {
 			if ( dberror ) {
 				console.log( '- ' + shardId + ': ' + signal + ': Error while closing the database connection: ' + dberror );
 				return dberror;

+ 4 - 0
cmds/eval.js

@@ -1,6 +1,10 @@
 const util = require('util');
 util.inspect.defaultOptions = {compact:false,breakLength:Infinity};
 
+var allSites = [];
+const getAllSites = require('../util/allSites.js');
+getAllSites.then( sites => allSites = sites );
+
 const Discord = require('discord.js');
 const {limit: {verification: verificationLimit, rcgcdw: rcgcdwLimit}} = require('../util/default.json');
 const newMessage = require('../util/newMessage.js');

+ 3 - 3
cmds/wiki/gamepedia/overview.js

@@ -32,9 +32,9 @@ function gamepedia_overview(lang, msg, wiki, reaction, spoiler) {
 		}
 		else {
 			wiki.updateWiki(body.query.general);
-			var site = false;
-			if ( allSites.some( site => site.wiki_domain === body.hostname ) ) {
-				site = allSites.find( site => site.wiki_domain === body.hostname );
+			var site = null;
+			if ( allSites.some( site => site.wiki_domain === wiki.hostname ) ) {
+				site = allSites.find( site => site.wiki_domain === wiki.hostname );
 				
 				var name = [lang.get('overview.name'), site.wiki_display_name];
 				var created = [lang.get('overview.created'), new Date(parseInt(site.created + '000', 10)).toLocaleString(lang.get('dateformat'), timeoptions)];

+ 4 - 3
dashboard/index.js

@@ -441,17 +441,18 @@ function hasPerm(all, permission, admin = true) {
  * End the process gracefully.
  * @param {NodeJS.Signals} signal - The signal received.
  */
-async function graceful(signal) {
+function graceful(signal) {
 	console.log( '- Dashboard: ' + signal + ': Closing the dashboard...' );
-	await server.close( () => {
+	server.close( () => {
 		console.log( '- Dashboard: ' + signal + ': Closed the dashboard server.' );
 	} );
-	await db.close( dberror => {
+	db.close( dberror => {
 		if ( dberror ) {
 			console.log( '- Dashboard: ' + signal + ': Error while closing the database connection: ' + dberror );
 			return dberror;
 		}
 		console.log( '- Dashboard: ' + signal + ': Closed the database connection.' );
+		process.exit(0);
 	} );
 }
 

+ 3 - 2
main.js

@@ -35,6 +35,7 @@ manager.on( 'shardCreate', shard => {
 		if ( message === 'SIGKILL' ) {
 			console.log( '\n- Killing all shards!\n\n' );
 			manager.shards.forEach( shard => shard.kill() );
+			if ( typeof server !== 'undefined' ) server.kill();
 		}
 		if ( message === 'postStats' && process.env.botlist ) postStats();
 	} );
@@ -157,7 +158,7 @@ function postStats(botList = JSON.parse(process.env.botlist), shardCount = manag
  * End the process gracefully.
  * @param {NodeJS.Signals} signal - The signal received.
  */
-async function graceful(signal) {
+function graceful(signal) {
 	console.log( '- ' + signal + ': Disabling respawn...' );
 	manager.respawn = false;
 }
@@ -176,5 +177,5 @@ if ( isDebug && process.argv[3]?.startsWith( '--timeout:' ) ) {
 		console.log( `\n- Running for ${timeout} seconds, closing process!\n` );
 		manager.shards.forEach( shard => shard.kill() );
 		if ( typeof server !== 'undefined' ) server.kill();
-	}, timeout  * 1000 ).unref();
+	}, timeout * 1000 ).unref();
 }

+ 2 - 2
util/newMessage.js

@@ -227,10 +227,10 @@ function newMessage(msg, lang, wiki = defaultSettings.wiki, prefix = process.env
 			}
 			if ( embeds.length ) {
 				if ( wiki.isFandom() ) embeds.forEach( embed => msg.reactEmoji('⏳').then( reaction => {
-					check_wiki.fandom(lang, msg, embed.title, wiki, '', reaction, embed.spoiler, '', embed.section);
+					check_wiki.fandom(lang, msg, embed.title, wiki, '', reaction, embed.spoiler, new URLSearchParams(), embed.section);
 				} ) );
 				else embeds.forEach( embed => msg.reactEmoji('⏳').then( reaction => {
-					check_wiki.gamepedia(lang, msg, embed.title, wiki, '', reaction, embed.spoiler, '', embed.section);
+					check_wiki.gamepedia(lang, msg, embed.title, wiki, '', reaction, embed.spoiler, new URLSearchParams(), embed.section);
 				} ) );
 			}
 		}, error => {