浏览代码

minor improvements

Markus-Rost 6 年之前
父节点
当前提交
21aa86dff3
共有 3 个文件被更改,包括 22 次插入27 次删除
  1. 3 4
      .gitignore
  2. 2 2
      i18n.json
  3. 17 21
      main.js

+ 3 - 4
.gitignore

@@ -1,5 +1,4 @@
-
-*.env
-node_modules*
-*.bat
+node_modules/
 package-lock.json
+*.env
+*.bat

+ 2 - 2
i18n.json

@@ -50,7 +50,7 @@
 			"save_failed": "sadly the settings couldn't be saved, please try again later.",
 			"missing": "this server isn't set up yet. Use %1$s and %2$s to change the settings.",
 			"foundwikis": "Do you mean any of these wikis?",
-			"current": "this are the current settings for this server:\nLanguage: `English` %1$s\nDefault wiki: %2$s\nChannel wikis",
+			"current": "these are the current settings for this server:\nLanguage: `English` %1$s\nDefault wiki: %2$s\nChannel wikis",
 			"nochannels": "*No channel wikis yet*",
 			"lang": "the language for this server is: `English`",
 			"langinvalid": "the specified language is not supported!",
@@ -76,7 +76,7 @@
 			"left": "%1$s left the voice channel \"%2$s\"."
 		},
 		"overview": {
-			"missing": "for this wiki is no overview available yet.",
+			"missing": "there is no overview available for this wiki yet.",
 			"inaccurate": "Statistics may be inaccurate",
 			"name": "Full name:",
 			"created": "Created:",

+ 17 - 21
main.js

@@ -1,5 +1,4 @@
 require('dotenv').config();
-const fs = require('fs');
 const util = require('util');
 util.inspect.defaultOptions = {compact:false,breakLength:Infinity};
 
@@ -7,19 +6,28 @@ const Discord = require('discord.js');
 const DBL = require("dblapi.js");
 var request = require('request');
 
-var isDebug = ( process.argv[2] === 'debug' ? true : false );
-var multiManager = require('./wiki_manager.json');
-
 var client = new Discord.Client( {disableEveryone:true} );
 const dbl = new DBL(process.env.dbltoken);
 
 var i18n = require('./i18n.json');
 var minecraft = require('./minecraft.json');
+var multiManager = require('./wiki_manager.json');
 
 var pause = {};
 var stop = false;
+var isDebug = ( process.argv[2] === 'debug' ? true : false );
 const access = {'PRIVATE-TOKEN': process.env.access};
-var defaultPermissions = new Discord.Permissions(268954688).toArray();
+const defaultPermissions = new Discord.Permissions(268954688).toArray();
+const timeoptions = {
+	year: 'numeric',
+	month: 'short',
+	day: 'numeric',
+	hour: '2-digit',
+	minute: '2-digit',
+	timeZone: 'UTC',
+	timeZoneName: 'short'
+}
+
 
 var ready = {
 	settings: true,
@@ -61,8 +69,7 @@ function setStatus() {
 	}
 }
 
-var defaultSites = [];
-var allSites = defaultSites;
+var allSites = [];
 
 function getAllSites() {
 	ready.allSites = true;
@@ -100,17 +107,6 @@ client.on( 'ready', () => {
 		} );
 	}, 10800000);
 } );
-
-
-var timeoptions = {
-	year: 'numeric',
-	month: 'short',
-	day: 'numeric',
-	hour: '2-digit',
-	minute: '2-digit',
-	timeZone: 'UTC',
-	timeZoneName: 'short'
-}
 	
 	
 var cmdmap = {
@@ -539,7 +535,7 @@ function check_wiki(lang, msg, title, wiki, cmd, reaction, spoiler = '', queryst
 				}
 				else {
 					console.log( '- Fehler beim Erhalten der Suchergebnisse' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
-					msg.sendChannelError( spoiler + '<https://' + wiki + '.gamepedia.com/' + ( linksuffix ? title.toTitle() + linksuffix : 'Special:Search/' + title.toTitle() ) + '>' + spoiler );
+					msg.sendChannelError( spoiler + '<https://' + wiki + '.gamepedia.com/' + ( linksuffix || !title ? title.toTitle() + linksuffix : 'Special:Search/' + title.toTitle() ) + '>' + spoiler );
 				}
 				
 				if ( reaction ) reaction.removeEmoji();
@@ -1507,7 +1503,7 @@ client.on( 'message', msg => {
 	if ( channel.type === 'text' ) var permissions = channel.permissionsFor(client.user);
 	
 	if ( !ready.settings && settings === defaultSettings ) getSettings(setStatus);
-	if ( !ready.allSites && allSites === defaultSites ) getAllSites();
+	if ( !ready.allSites && !allSites.length ) getAllSites();
 	var setting = Object.assign({}, settings['default']);
 	if ( settings === defaultSettings ) {
 		msg.sendChannel( '⚠ **Limited Functionality** ⚠\nNo settings found, please contact the bot owner!\n' + process.env.invite, {}, true );
@@ -1569,7 +1565,7 @@ client.on( 'voiceStateUpdate', (oldm, newm) => {
 	if ( stop ) return;
 	
 	if ( !ready.settings && settings === defaultSettings ) getSettings(setStatus);
-	if ( !ready.allSites && allSites === defaultSites ) getAllSites();
+	if ( !ready.allSites && !allSites.length ) getAllSites();
 	if ( oldm.guild.me.permissions.has('MANAGE_ROLES') && oldm.voiceChannelID !== newm.voiceChannelID ) {
 		var setting = Object.assign({}, settings['default']);
 		if ( oldm.guild.id in settings ) setting = Object.assign({}, settings[oldm.guild.id]);