Forráskód Böngészése

fixed crash

fixed most recent crash and added some custom user groups
Markus-Rost 6 éve
szülő
commit
3037b22550
4 módosított fájl, 36 hozzáadás és 53 törlés
  1. 0 24
      .github/ISSUE_TEMPLATE/bug_report.md
  2. 0 17
      .github/ISSUE_TEMPLATE/feature_request.md
  3. 15 0
      i18n.json
  4. 21 12
      main.js

+ 0 - 24
.github/ISSUE_TEMPLATE/bug_report.md

@@ -1,24 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior:
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**Additional context**
-Add any other context about the problem here.

+ 0 - 17
.github/ISSUE_TEMPLATE/feature_request.md

@@ -1,17 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.

+ 15 - 0
i18n.json

@@ -80,7 +80,10 @@
 				["sysop", "Administrator"],
 				["sysop", "Administrator"],
 				["grasp", "GRASP"],
 				["grasp", "GRASP"],
 				["directors", "Director"],
 				["directors", "Director"],
+				["Patrol", "Inspector"],
 				["editor", "Editor"],
 				["editor", "Editor"],
+				["moderator", "Moderator"],
+				["Elite_users", "Elite user"],
 				["patrollers", "Patroller"],
 				["patrollers", "Patroller"],
 				["autoreview", "autoreview"],
 				["autoreview", "autoreview"],
 				["autopatrol", "autopatrol"],
 				["autopatrol", "autopatrol"],
@@ -225,7 +228,10 @@
 				["sysop", "Administrator"],
 				["sysop", "Administrator"],
 				["grasp", "GRASP"],
 				["grasp", "GRASP"],
 				["directors", "Direktor"],
 				["directors", "Direktor"],
+				["Patrol", "Inspektor"],
 				["editor", "Autor"],
 				["editor", "Autor"],
+				["moderator", "Moderator"],
+				["Elite_users", "Elite-Benutzer"],
 				["patrollers", "Kontrolleur"],
 				["patrollers", "Kontrolleur"],
 				["autoreview", "autoreview"],
 				["autoreview", "autoreview"],
 				["autopatrol", "autopatrol"],
 				["autopatrol", "autopatrol"],
@@ -383,7 +389,10 @@
 				["sysop", "Administrateur"],
 				["sysop", "Administrateur"],
 				["grasp", "GRASP"],
 				["grasp", "GRASP"],
 				["directors", "Directeur"],
 				["directors", "Directeur"],
+				["Patrol", "Inspecteur"],
 				["editor", "Éditeur"],
 				["editor", "Éditeur"],
+				["moderator", "Modérateur"],
+				["Elite_users", "Utilisateur élite"],
 				["patrollers", "Patrouilleur"],
 				["patrollers", "Patrouilleur"],
 				["autoreview", "autoreview"],
 				["autoreview", "autoreview"],
 				["autopatrol", "autopatrol"],
 				["autopatrol", "autopatrol"],
@@ -537,7 +546,10 @@
 				["sysop", "Adminsitrator"],
 				["sysop", "Adminsitrator"],
 				["GRASP", "GRASP"],
 				["GRASP", "GRASP"],
 				["directors", "Dyrektor"],
 				["directors", "Dyrektor"],
+				["Patrol", "Inspektor"],
 				["editor", "Redaktor"],
 				["editor", "Redaktor"],
+				["moderator", "Moderator"],
+				["Elite_users", "Elitarni użytkownicy"],
 				["patrollers", "Przeglądający"],
 				["patrollers", "Przeglądający"],
 				["autoreview", "autoreview"],
 				["autoreview", "autoreview"],
 				["autopatrol", "autopatrol"],
 				["autopatrol", "autopatrol"],
@@ -700,7 +712,10 @@
 				["sysop", "Administrador"],
 				["sysop", "Administrador"],
 				["grasp", "GRASP"],
 				["grasp", "GRASP"],
 				["directors", "Diretor"],
 				["directors", "Diretor"],
+				["Patrol", "Inspetor"],
 				["editor", "Editor"],
 				["editor", "Editor"],
+				["moderator", "Moderador"],
+				["Elite_users", "Usuário elite"],
 				["patrollers", "Patrulheiro"],
 				["patrollers", "Patrulheiro"],
 				["autoreview", "revisão automática"],
 				["autoreview", "revisão automática"],
 				["autopatrol", "autopatrulha"],
 				["autopatrol", "autopatrulha"],

+ 21 - 12
main.js

@@ -15,6 +15,11 @@ var minecraft = JSON.parse(fs.readFileSync('minecraft.json', 'utf8').trim());
 var pause = {};
 var pause = {};
 var defaultPermissions = new Discord.Permissions(268954688).toArray();
 var defaultPermissions = new Discord.Permissions(268954688).toArray();
 
 
+var ready = {
+	settings: true,
+	allSites: true
+}
+
 var defaultSettings = {
 var defaultSettings = {
 	"default": {
 	"default": {
 		"lang": "en",
 		"lang": "en",
@@ -24,12 +29,14 @@ var defaultSettings = {
 var settings = defaultSettings;
 var settings = defaultSettings;
 
 
 function getSettings(callback) {
 function getSettings(callback) {
+	ready.settings = true;
 	request( {
 	request( {
 		uri: process.env.read + process.env.file + process.env.access,
 		uri: process.env.read + process.env.file + process.env.access,
 		json: true
 		json: true
 	}, function( error, response, body ) {
 	}, function( error, response, body ) {
 		if ( error || !response || !body || body.error ) {
 		if ( error || !response || !body || body.error ) {
 			console.log( '- Fehler beim Erhalten der Einstellungen' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error : '.' ) : '.' ) ) );
 			console.log( '- Fehler beim Erhalten der Einstellungen' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error : '.' ) : '.' ) ) );
+			ready.settings = false;
 		}
 		}
 		else {
 		else {
 			console.log( '- Einstellungen erfolgreich ausgelesen.' );
 			console.log( '- Einstellungen erfolgreich ausgelesen.' );
@@ -51,12 +58,14 @@ var defaultSites = [];
 var allSites = defaultSites;
 var allSites = defaultSites;
 
 
 function getAllSites() {
 function getAllSites() {
+	ready.allSites = true;
 	request( {
 	request( {
 		uri: 'https://help.gamepedia.com/api.php?action=allsites&format=json&formatversion=2&do=getSiteStats&filter=wikis|wiki_domain,wiki_display_name,official_wiki,wiki_managers',
 		uri: 'https://help.gamepedia.com/api.php?action=allsites&format=json&formatversion=2&do=getSiteStats&filter=wikis|wiki_domain,wiki_display_name,official_wiki,wiki_managers',
 		json: true
 		json: true
 	}, function( error, response, body ) {
 	}, function( error, response, body ) {
 		if ( error || !response || !body || body.status != 'okay' || !body.data || !body.data.wikis ) {
 		if ( error || !response || !body || body.status != 'okay' || !body.data || !body.data.wikis ) {
 			console.log( '- Fehler beim Erhalten der Wikis' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
 			console.log( '- Fehler beim Erhalten der Wikis' + ( error ? ': ' + error : ( body ? ( body.error ? ': ' + body.error.info : '.' ) : '.' ) ) );
+			ready.allSites = false;
 		}
 		}
 		else {
 		else {
 			console.log( '- Wikis erfolgreich ausgelesen.' );
 			console.log( '- Wikis erfolgreich ausgelesen.' );
@@ -210,7 +219,7 @@ function edit_settings(lang, msg, key, value) {
 		if ( settings == defaultSettings ) {
 		if ( settings == defaultSettings ) {
 			console.log( '- Fehler beim Erhalten bestehender Einstellungen.' );
 			console.log( '- Fehler beim Erhalten bestehender Einstellungen.' );
 			msg.reply( lang.settings.save_failed );
 			msg.reply( lang.settings.save_failed );
-			reaction.removeEmoji();
+			if ( reaction ) reaction.removeEmoji();
 		}
 		}
 		else {
 		else {
 			var temp_settings = Object.assign({}, settings);
 			var temp_settings = Object.assign({}, settings);
@@ -258,7 +267,7 @@ function edit_settings(lang, msg, key, value) {
 					console.log( '- Einstellungen erfolgreich aktualisiert.' );
 					console.log( '- Einstellungen erfolgreich aktualisiert.' );
 				}
 				}
 				
 				
-				reaction.removeEmoji();
+				if ( reaction ) reaction.removeEmoji();
 			} );
 			} );
 		}
 		}
 	} );
 	} );
@@ -509,7 +518,7 @@ function cmd_link(lang, msg, title, wiki = lang.link, cmd = ' ', querystring = '
 									}
 									}
 									else {
 									else {
 										var pagelink = 'https://' + wiki + '.gamepedia.com/' + srbody.query.search[0].title.toTitle() + linksuffix;
 										var pagelink = 'https://' + wiki + '.gamepedia.com/' + srbody.query.search[0].title.toTitle() + linksuffix;
-										if ( title.toTitle().toLowerCase() == srbody.query.search[0].title.toTitle().toLowerCase() ) {
+										if ( title.replace( /\-/g, ' ' ).toTitle().toLowerCase() == srbody.query.search[0].title.replace( /\-/g, ' ' ).toTitle().toLowerCase() ) {
 											msg.channel.send( pagelink );
 											msg.channel.send( pagelink );
 										}
 										}
 										else if ( srbody.query.searchinfo.totalhits == 1 ) {
 										else if ( srbody.query.searchinfo.totalhits == 1 ) {
@@ -540,7 +549,7 @@ function cmd_link(lang, msg, title, wiki = lang.link, cmd = ' ', querystring = '
 					}
 					}
 				}
 				}
 				
 				
-				reaction.removeEmoji();
+				if ( reaction ) reaction.removeEmoji();
 			} );
 			} );
 		} );
 		} );
 	}
 	}
@@ -674,7 +683,7 @@ function cmd_user(lang, msg, username, wiki, title, cmd, querystring, fragment)
 					}
 					}
 				}
 				}
 				
 				
-				reaction.removeEmoji();
+				if ( reaction ) reaction.removeEmoji();
 			} );
 			} );
 		} );
 		} );
 	}
 	}
@@ -766,7 +775,7 @@ function cmd_diff(lang, msg, args, wiki) {
 						}
 						}
 					}
 					}
 					
 					
-					reaction.removeEmoji();
+					if ( reaction ) reaction.removeEmoji();
 				} );
 				} );
 			} );
 			} );
 		}
 		}
@@ -855,7 +864,7 @@ function cmd_random(lang, msg, wiki) {
 				msg.channel.send( '🎲 https://' + wiki + '.gamepedia.com/' + body.query.random[0].title.toTitle() );
 				msg.channel.send( '🎲 https://' + wiki + '.gamepedia.com/' + body.query.random[0].title.toTitle() );
 			}
 			}
 			
 			
-			reaction.removeEmoji();
+			if ( reaction ) reaction.removeEmoji();
 		} );
 		} );
 	} );
 	} );
 }
 }
@@ -891,7 +900,7 @@ function cmd_bug(lang, mclang, msg, args, title, cmd, querystring, fragment) {
 					}
 					}
 				}
 				}
 				
 				
-				reaction.removeEmoji();
+				if ( reaction ) reaction.removeEmoji();
 			} );
 			} );
 		} );
 		} );
 	}
 	}
@@ -1040,8 +1049,8 @@ client.on('message', msg => {
 	if ( channel.type == 'text' ) var permissions = channel.permissionsFor(client.user);
 	if ( channel.type == 'text' ) var permissions = channel.permissionsFor(client.user);
 	
 	
 	if ( cont.toLowerCase().includes( process.env.prefix ) && !msg.webhookID && author.id != client.user.id ) {
 	if ( cont.toLowerCase().includes( process.env.prefix ) && !msg.webhookID && author.id != client.user.id ) {
-		if ( settings == defaultSettings ) getSettings(setStatus);
-		if ( allSites == defaultSites ) getAllSites();
+		if ( !ready.settings && settings == defaultSettings ) getSettings(setStatus);
+		if ( !ready.allSites && allSites == defaultSites ) getAllSites();
 		var setting = Object.assign({}, settings['default']);
 		var setting = Object.assign({}, settings['default']);
 		if ( channel.type == 'text' && msg.guild.id in settings ) setting = Object.assign({}, settings[msg.guild.id]);
 		if ( channel.type == 'text' && msg.guild.id in settings ) setting = Object.assign({}, settings[msg.guild.id]);
 		var lang = i18n[setting.lang];
 		var lang = i18n[setting.lang];
@@ -1092,8 +1101,8 @@ client.on('message', msg => {
 
 
 
 
 client.on('voiceStateUpdate', (oldm, newm) => {
 client.on('voiceStateUpdate', (oldm, newm) => {
-	if ( settings == defaultSettings ) getSettings(setStatus);
-	if ( allSites == defaultSites ) getAllSites();
+	if ( !ready.settings && settings == defaultSettings ) getSettings(setStatus);
+	if ( !ready.allSites && allSites == defaultSites ) getAllSites();
 	if ( oldm.guild.me.permissions.has('MANAGE_ROLES') && oldm.voiceChannelID != newm.voiceChannelID ) {
 	if ( oldm.guild.me.permissions.has('MANAGE_ROLES') && oldm.voiceChannelID != newm.voiceChannelID ) {
 		var setting = Object.assign({}, settings['default']);
 		var setting = Object.assign({}, settings['default']);
 		if ( oldm.guild.id in settings ) setting = Object.assign({}, settings[oldm.guild.id]);
 		if ( oldm.guild.id in settings ) setting = Object.assign({}, settings[oldm.guild.id]);