1
0
Markus-Rost 5 жил өмнө
parent
commit
cc244e4a38
3 өөрчлөгдсөн 24 нэмэгдсэн , 24 устгасан
  1. 6 6
      .env.example
  2. 12 12
      main.js
  3. 6 6
      package.json

+ 6 - 6
.env.example

@@ -15,16 +15,16 @@ invite="https://discord.gg/v77RTk5"
 # Link to the patreon page for the bot
 patreon="https://www.patreon.com/WikiBot"
 
-# Token to send server count to https://discordbots.org/
+# Token to send server count to https://discordbots.org/ (optional)
 dbltoken="<token>"
-# Token to send server count to https://discord.bots.gg/
+# Token to send server count to https://discord.bots.gg/ (optional)
 dbggtoken="<token>"
 
-# Username to log into an account on Gamepedia
+# Username to log into an account on Gamepedia (optional)
 gpusername="<username>"
-# Password to log into an account on Gamepedia
+# Password to log into an account on Gamepedia (optional)
 gppassword="<password>"
-# Username to log into an account on Fandom
+# Username to log into an account on Fandom (optional)
 fusername="<username>"
-# Password to log into an account on Fandom
+# Password to log into an account on Fandom (optional)
 fpassword="<password>"

+ 12 - 12
main.js

@@ -89,10 +89,10 @@ function fWikiLogin(token) {
 if ( process.env.fusername && process.env.fpassword ) fWikiLogin();
 
 var client = new Discord.Client( {
-	messageCacheLifetime: 600,
-	messageSweepInterval: 6000,
+	messageCacheLifetime: 300,
+	messageSweepInterval: 300,
 	disableEveryone: true,
-	disabledEvents: ["TYPING_START"]
+	disabledEvents: ['CHANNEL_PINS_UPDATE','USER_NOTE_UPDATE','PRESENCE_UPDATE','TYPING_START']
 } );
 const dbl = new DBL(process.env.dbltoken);
 
@@ -661,7 +661,7 @@ function cmd_voice(lang, msg, args, line, wiki) {
 					}
 					console.log( '- Voice settings successfully added.' );
 					voice[msg.guild.id] = defaultSettings.lang;
-					msg.replyMsg( lang.voice.enabled, {}, true );
+					msg.replyMsg( lang.voice.enabled + '\n`' + lang.voice.channel + ' – <' + lang.voice.name + '>`', {}, true );
 				} );
 				console.log( '- Voice settings successfully updated.' );
 				if ( value ) {
@@ -674,7 +674,7 @@ function cmd_voice(lang, msg, args, line, wiki) {
 						console.log( '- Voice language successfully updated.' );
 						voice[msg.guild.id] = row.lang;
 					} );
-					msg.replyMsg( lang.voice.enabled, {}, true );
+					msg.replyMsg( lang.voice.enabled + '\n`' + lang.voice.channel + ' – <' + lang.voice.name + '>`', {}, true );
 				}
 				else {
 					delete voice[msg.guild.id];
@@ -2493,7 +2493,7 @@ function global_block(lang, msg, username, text, embed, wiki, spoiler) {
 				let $ = cheerio.load(gbody);
 				var globaledits = $('#editcount .TablePager th').eq(7).text().replace( /[,\.]/g, '' );
 				if ( globaledits ) {
-					if ( msg.showEmbed() ) embed.fields.splice(1, 0, {name:lang.user.info.globaleditcount,value:globaledits,inline:true});
+					if ( msg.showEmbed() ) embed.spliceFields(1, 0, {name:lang.user.info.globaleditcount,value:globaledits,inline:true});
 					else {
 						let splittext = text.split('\n');
 						splittext.splice(5, 0, lang.user.info.globaleditcount + ' ' + globaledits);
@@ -2551,7 +2551,7 @@ function global_block(lang, msg, username, text, embed, wiki, spoiler) {
 				let $ = cheerio.load(gbody);
 				var wikisedited = $('.curseprofile .rightcolumn .section.stats dd').eq(0).text().replace( /[,\.]/g, '' );
 				if ( wikisedited ) {
-					if ( msg.showEmbed() ) embed.fields.splice(1, 0, {name:lang.user.info.wikisedited,value:wikisedited,inline:true});
+					if ( msg.showEmbed() ) embed.spliceFields(1, 0, {name:lang.user.info.wikisedited,value:wikisedited,inline:true});
 					else {
 						let splittext = text.split('\n');
 						splittext.splice(5, 0, lang.user.info.wikisedited + ' ' + wikisedited);
@@ -2560,7 +2560,7 @@ function global_block(lang, msg, username, text, embed, wiki, spoiler) {
 				}
 				var globaledits = $('.curseprofile .rightcolumn .section.stats dd').eq(2).text().replace( /[,\.]/g, '' );
 				if ( globaledits ) {
-					if ( msg.showEmbed() ) embed.fields.splice(1, 0, {name:lang.user.info.globaleditcount,value:globaledits,inline:true});
+					if ( msg.showEmbed() ) embed.spliceFields(1, 0, {name:lang.user.info.globaleditcount,value:globaledits,inline:true});
 					else {
 						let splittext = text.split('\n');
 						splittext.splice(5, 0, lang.user.info.globaleditcount + ' ' + globaledits);
@@ -3063,7 +3063,7 @@ function gamepedia_diff(lang, msg, args, wiki, reaction, spoiler, embed) {
 
 function gamepedia_diffsend(lang, msg, args, wiki, reaction, spoiler, compare) {
 	request( {
-		uri: wiki + 'api.php?action=query&meta=siteinfo&siprop=general&list=tags&tglimit=500&tgprop=displayname&prop=revisions&rvprop=ids|timestamp|flags|user|size|comment|tags' + ( args.length === 1 || args[0] === args[1] ? '|content' : '' ) + '&revids=' + args.join('|') + '&format=json',
+		uri: wiki + 'api.php?action=query&meta=siteinfo&siprop=general&list=tags&tglimit=500&tgprop=displayname&prop=revisions&rvslots=main&rvprop=ids|timestamp|flags|user|size|comment|tags' + ( args.length === 1 || args[0] === args[1] ? '|content' : '' ) + '&revids=' + args.join('|') + '&format=json',
 		json: true
 	}, function( error, response, body ) {
 		if ( body && body.warnings ) log_warn(body.warnings);
@@ -4727,7 +4727,7 @@ Discord.Message.prototype.deleteMsg = function(timeout = 0) {
 };
 
 Discord.Message.prototype.allowDelete = function(author) {
-	return this.awaitReactions( (reaction, user) => reaction.emoji.name === '🗑️' && user.id === author, {max:1,time:60000} ).then( reaction => {
+	return this.awaitReactions( (reaction, user) => reaction.emoji.name === '🗑️' && user.id === author, {max:1,time:120000} ).then( reaction => {
 		if ( reaction.size ) {
 			this.deleteMsg();
 		}
@@ -4739,7 +4739,7 @@ String.prototype.hasPrefix = function(prefix, flags = '') {
 };
 
 client.on( 'message', msg => {
-	if ( stop || msg.type !== 'DEFAULT' || msg.webhookID || msg.author.id === client.user.id ) return;
+	if ( stop || msg.type !== 'DEFAULT' || msg.system || msg.webhookID || msg.author.id === client.user.id ) return;
 	if ( !msg.content.hasPrefix(( msg.channel.type === 'text' && patreons[msg.guild.id] || process.env.prefix ), 'm') ) {
 		if ( msg.content === process.env.prefix + ' help' && ( msg.isAdmin() || msg.isOwner() ) ) {
 			if ( msg.channel.permissionsFor(client.user).has('SEND_MESSAGES') ) {
@@ -5156,7 +5156,7 @@ async function graceful(code = 0) {
 			console.log( '- SIGTERM: Closing takes too long, terminating!' );
 			process.exit(code);
 		}, 2000 ).unref();
-	}, 2000 ).unref();
+	}, 1000 ).unref();
 }
 
 process.once( 'SIGINT', graceful );

+ 6 - 6
package.json

@@ -11,14 +11,14 @@
   "license": "ISC",
   "dependencies": {
     "cheerio": "^1.0.0-rc.3",
-    "dblapi.js": "^2.3.0",
-    "discord.js": "^11.5.1",
+    "dblapi.js": "^2.3.1",
+    "discord.js": "^11.6.0",
     "dotenv": "^6.2.0",
-    "full-icu": "^1.3.0",
+    "full-icu": "^1.3.1",
     "htmlparser2": "^3.10.1",
-    "npm": "^6.12.0",
-    "request": "^2.88.0",
-    "sqlite3": "^4.1.0"
+    "npm": "^6.14.1",
+    "request": "^2.88.2",
+    "sqlite3": "^4.1.1"
   },
   "repository": {
     "type": "git",