mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Moved emote cmds to utility category.
Updated Discord.JS version to 12.4.0. Added channelCreate/remove events. Removed husky.
This commit is contained in:
		
							parent
							
								
									74b4d4272c
								
							
						
					
					
						commit
						0c0fc083cf
					
				
					 10 changed files with 110 additions and 95 deletions
				
			
		
							
								
								
									
										1
									
								
								.husky/.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.husky/.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +0,0 @@ | ||||||
| _ |  | ||||||
|  | @ -1,4 +0,0 @@ | ||||||
| #!/bin/sh |  | ||||||
| . "$(dirname $0)/_/husky.sh" |  | ||||||
| 
 |  | ||||||
| npm test && npx prettier --write . |  | ||||||
							
								
								
									
										48
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										48
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -5,9 +5,9 @@ | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@discordjs/collection": { |     "@discordjs/collection": { | ||||||
|       "version": "0.1.5", |       "version": "0.1.6", | ||||||
|       "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz", |       "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", | ||||||
|       "integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw==" |       "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==" | ||||||
|     }, |     }, | ||||||
|     "@discordjs/form-data": { |     "@discordjs/form-data": { | ||||||
|       "version": "3.0.1", |       "version": "3.0.1", | ||||||
|  | @ -359,30 +359,18 @@ | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "discord.js": { |     "discord.js": { | ||||||
|       "version": "12.2.0", |       "version": "12.4.0", | ||||||
|       "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.2.0.tgz", |       "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.4.0.tgz", | ||||||
|       "integrity": "sha512-Ueb/0SOsxXyqwvwFYFe0msMrGqH1OMqpp2Dpbplnlr4MzcRrFWwsBM9gKNZXPVBHWUKiQkwU8AihXBXIvTTSvg==", |       "integrity": "sha512-Lc+/vKzih1DPEya/0MO0BAp4Ru/4+MfDsOJkfbyzGoyIlFqiWSQ78RdyRk4tqAtabl6d5QR4Ygo0Ub0TGEsXBg==", | ||||||
|       "requires": { |       "requires": { | ||||||
|         "@discordjs/collection": "^0.1.5", |         "@discordjs/collection": "^0.1.6", | ||||||
|         "@discordjs/form-data": "^3.0.1", |         "@discordjs/form-data": "^3.0.1", | ||||||
|         "abort-controller": "^3.0.0", |         "abort-controller": "^3.0.0", | ||||||
|         "node-fetch": "^2.6.0", |         "node-fetch": "^2.6.1", | ||||||
|         "prism-media": "^1.2.0", |         "prism-media": "^1.2.2", | ||||||
|         "setimmediate": "^1.0.5", |         "setimmediate": "^1.0.5", | ||||||
|         "tweetnacl": "^1.0.3", |         "tweetnacl": "^1.0.3", | ||||||
|         "ws": "^7.2.1" |         "ws": "^7.3.1" | ||||||
|       }, |  | ||||||
|       "dependencies": { |  | ||||||
|         "prism-media": { |  | ||||||
|           "version": "1.2.2", |  | ||||||
|           "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz", |  | ||||||
|           "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==" |  | ||||||
|         }, |  | ||||||
|         "ws": { |  | ||||||
|           "version": "7.3.0", |  | ||||||
|           "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", |  | ||||||
|           "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==" |  | ||||||
|         } |  | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "duplexer": { |     "duplexer": { | ||||||
|  | @ -610,12 +598,6 @@ | ||||||
|       "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", |       "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|     "husky": { |  | ||||||
|       "version": "5.0.0-alpha.6", |  | ||||||
|       "resolved": "https://registry.npmjs.org/husky/-/husky-5.0.0-alpha.6.tgz", |  | ||||||
|       "integrity": "sha512-Ofqq0oHLCO0r8hTb/1PQ3FAfsW945adUli8jFTeXdOIK8gCUmxY9A0BI0mG9oGboPf+Y53bvEmX6ljdrz+yV6w==", |  | ||||||
|       "dev": true |  | ||||||
|     }, |  | ||||||
|     "iconv-lite": { |     "iconv-lite": { | ||||||
|       "version": "0.4.24", |       "version": "0.4.24", | ||||||
|       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", |       "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", | ||||||
|  | @ -1044,6 +1026,11 @@ | ||||||
|       "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", |       "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|  |     "prism-media": { | ||||||
|  |       "version": "1.2.2", | ||||||
|  |       "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz", | ||||||
|  |       "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==" | ||||||
|  |     }, | ||||||
|     "promise.allsettled": { |     "promise.allsettled": { | ||||||
|       "version": "1.0.2", |       "version": "1.0.2", | ||||||
|       "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz", |       "resolved": "https://registry.npmjs.org/promise.allsettled/-/promise.allsettled-1.0.2.tgz", | ||||||
|  | @ -1480,6 +1467,11 @@ | ||||||
|       "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", |       "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", | ||||||
|       "dev": true |       "dev": true | ||||||
|     }, |     }, | ||||||
|  |     "ws": { | ||||||
|  |       "version": "7.3.1", | ||||||
|  |       "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", | ||||||
|  |       "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" | ||||||
|  |     }, | ||||||
|     "y18n": { |     "y18n": { | ||||||
|       "version": "4.0.0", |       "version": "4.0.0", | ||||||
|       "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", |       "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", | ||||||
|  |  | ||||||
|  | @ -6,7 +6,7 @@ | ||||||
|   "private": true, |   "private": true, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "chalk": "^4.1.0", |     "chalk": "^4.1.0", | ||||||
|     "discord.js": "^12.2.0", |     "discord.js": "^12.4.0", | ||||||
|     "inquirer": "^7.3.1", |     "inquirer": "^7.3.1", | ||||||
|     "moment": "^2.27.0" |     "moment": "^2.27.0" | ||||||
|   }, |   }, | ||||||
|  | @ -15,7 +15,6 @@ | ||||||
|     "@types/mocha": "^8.0.3", |     "@types/mocha": "^8.0.3", | ||||||
|     "@types/node": "^14.0.22", |     "@types/node": "^14.0.22", | ||||||
|     "@types/ws": "^7.2.6", |     "@types/ws": "^7.2.6", | ||||||
|     "husky": "^5.0.0-alpha.6", |  | ||||||
|     "mocha": "^8.1.2", |     "mocha": "^8.1.2", | ||||||
|     "prettier": "2.1.2", |     "prettier": "2.1.2", | ||||||
|     "ts-node": "^9.0.0", |     "ts-node": "^9.0.0", | ||||||
|  | @ -23,7 +22,6 @@ | ||||||
|     "typescript": "^3.9.6" |     "typescript": "^3.9.6" | ||||||
|   }, |   }, | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "postinstall": "husky install", |  | ||||||
|     "build": "tsc && npm prune --production", |     "build": "tsc && npm prune --production", | ||||||
|     "start": "node dist/index.js", |     "start": "node dist/index.js", | ||||||
|     "once": "tsc && npm start", |     "once": "tsc && npm start", | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ import { CommonLibrary, logs, botHasPermission } from '../core/lib'; | ||||||
| import { Config, Storage } from '../core/structures'; | import { Config, Storage } from '../core/structures'; | ||||||
| import { PermissionNames, getPermissionLevel } from '../core/permissions'; | import { PermissionNames, getPermissionLevel } from '../core/permissions'; | ||||||
| import { Permissions } from 'discord.js'; | import { Permissions } from 'discord.js'; | ||||||
|  | import * as discord from 'discord.js'; | ||||||
| 
 | 
 | ||||||
| function getLogBuffer(type: string) { | function getLogBuffer(type: string) { | ||||||
|   return { |   return { | ||||||
|  | @ -107,6 +108,9 @@ export default new Command({ | ||||||
|       description: 'Purges bot messages.', |       description: 'Purges bot messages.', | ||||||
|       permission: Command.PERMISSIONS.BOT_SUPPORT, |       permission: Command.PERMISSIONS.BOT_SUPPORT, | ||||||
|       async run($: CommonLibrary): Promise<any> { |       async run($: CommonLibrary): Promise<any> { | ||||||
|  |         if ($.message.channel instanceof discord.DMChannel) { | ||||||
|  |           return; | ||||||
|  |         } | ||||||
|         $.message.delete(); |         $.message.delete(); | ||||||
|         const msgs = await $.channel.messages.fetch({ |         const msgs = await $.channel.messages.fetch({ | ||||||
|           limit: 100, |           limit: 100, | ||||||
|  |  | ||||||
|  | @ -1,59 +0,0 @@ | ||||||
| import { MessageEmbed } from 'discord.js'; |  | ||||||
| import Command from '../core/command'; |  | ||||||
| import { CommonLibrary } from '../core/lib'; |  | ||||||
| 
 |  | ||||||
| export default new Command({ |  | ||||||
|   description: 'Various utilities.', |  | ||||||
|   endpoint: false, |  | ||||||
|   usage: '', |  | ||||||
|   async run($: CommonLibrary): Promise<any> {}, |  | ||||||
|   subcommands: { |  | ||||||
|     lsemotes: new Command({ |  | ||||||
|       description: "Lists all emotes the bot has in it's registry,", |  | ||||||
|       endpoint: true, |  | ||||||
|       async run($: CommonLibrary): Promise<any> { |  | ||||||
|         const nsfw: string | string[] = []; |  | ||||||
|         const pages = $.client.emojis.cache |  | ||||||
|           .filter((x) => !nsfw.includes(x.guild.id), this) |  | ||||||
|           .array(); |  | ||||||
|         const pagesSplit = $(pages).split(20); |  | ||||||
|         $.log(pagesSplit); |  | ||||||
|         var embed = new MessageEmbed() |  | ||||||
|           .setTitle('**Emoji list!**') |  | ||||||
|           .setColor('AQUA'); |  | ||||||
|         let desc = ''; |  | ||||||
|         for (const emote of pagesSplit[0]) { |  | ||||||
|           desc += `${emote} | ${emote.name}\n`; |  | ||||||
|         } |  | ||||||
|         embed.setDescription(desc); |  | ||||||
|         const msg = await $.channel.send({ embed }); |  | ||||||
| 
 |  | ||||||
|         $.paginate(msg, $.author.id, pages.length, (page) => { |  | ||||||
|           let desc = ''; |  | ||||||
|           for (const emote of pagesSplit[page]) { |  | ||||||
|             desc += `${emote} | ${emote.name}\n`; |  | ||||||
|           } |  | ||||||
|           embed.setDescription(desc); |  | ||||||
|           msg.edit(embed); |  | ||||||
|         }); |  | ||||||
|       }, |  | ||||||
|     }), |  | ||||||
|     emote: new Command({ |  | ||||||
|       description: 'Send the specified emote.', |  | ||||||
|       run: 'Please provide a command name.', |  | ||||||
|       any: new Command({ |  | ||||||
|         description: 'The emote to send.', |  | ||||||
|         usage: '<emote>', |  | ||||||
|         async run($: CommonLibrary): Promise<any> { |  | ||||||
|           const search = $.args[0].toLowerCase(); |  | ||||||
|           const emote = $.client.emojis.cache.find((emote) => |  | ||||||
|             emote.name.toLowerCase().includes(search), |  | ||||||
|           ); |  | ||||||
|           if (!emote) return $.channel.send("That's not a valid emote name!"); |  | ||||||
|           $.message.delete(); |  | ||||||
|           $.channel.send(`${emote}`); |  | ||||||
|         }, |  | ||||||
|       }), |  | ||||||
|     }), |  | ||||||
|   }, |  | ||||||
| }); |  | ||||||
							
								
								
									
										21
									
								
								src/commands/utilities/emote.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/commands/utilities/emote.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | ||||||
|  | import { MessageEmbed } from 'discord.js'; | ||||||
|  | import Command from '../../core/command'; | ||||||
|  | import { CommonLibrary } from '../../core/lib'; | ||||||
|  | 
 | ||||||
|  | export default new Command({ | ||||||
|  |   description: 'Send the specified emote.', | ||||||
|  |   run: 'Please provide a command name.', | ||||||
|  |   any: new Command({ | ||||||
|  |     description: 'The emote to send.', | ||||||
|  |     usage: '<emote>', | ||||||
|  |     async run($: CommonLibrary): Promise<any> { | ||||||
|  |       const search = $.args[0].toLowerCase(); | ||||||
|  |       const emote = $.client.emojis.cache.find((emote) => | ||||||
|  |         emote.name.toLowerCase().includes(search), | ||||||
|  |       ); | ||||||
|  |       if (!emote) return $.channel.send("That's not a valid emote name!"); | ||||||
|  |       $.message.delete(); | ||||||
|  |       $.channel.send(`${emote}`); | ||||||
|  |     }, | ||||||
|  |   }), | ||||||
|  | }); | ||||||
							
								
								
									
										32
									
								
								src/commands/utilities/lsemotes.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/commands/utilities/lsemotes.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | ||||||
|  | import { MessageEmbed } from 'discord.js'; | ||||||
|  | import Command from '../../core/command'; | ||||||
|  | import { CommonLibrary } from '../../core/lib'; | ||||||
|  | 
 | ||||||
|  | export default new Command({ | ||||||
|  |   description: "Lists all emotes the bot has in it's registry,", | ||||||
|  |   endpoint: true, | ||||||
|  |   async run($: CommonLibrary): Promise<any> { | ||||||
|  |     const nsfw: string | string[] = []; | ||||||
|  |     const pages = $.client.emojis.cache | ||||||
|  |       .filter((x) => !nsfw.includes(x.guild.id), this) | ||||||
|  |       .array(); | ||||||
|  |     const pagesSplit = $(pages).split(20); | ||||||
|  |     $.log(pagesSplit); | ||||||
|  |     var embed = new MessageEmbed().setTitle('**Emoji list!**').setColor('AQUA'); | ||||||
|  |     let desc = ''; | ||||||
|  |     for (const emote of pagesSplit[0]) { | ||||||
|  |       desc += `${emote} | ${emote.name}\n`; | ||||||
|  |     } | ||||||
|  |     embed.setDescription(desc); | ||||||
|  |     const msg = await $.channel.send({ embed }); | ||||||
|  | 
 | ||||||
|  |     $.paginate(msg, $.author.id, pages.length, (page) => { | ||||||
|  |       let desc = ''; | ||||||
|  |       for (const emote of pagesSplit[page]) { | ||||||
|  |         desc += `${emote} | ${emote.name}\n`; | ||||||
|  |       } | ||||||
|  |       embed.setDescription(desc); | ||||||
|  |       msg.edit(embed); | ||||||
|  |     }); | ||||||
|  |   }, | ||||||
|  | }); | ||||||
							
								
								
									
										16
									
								
								src/events/channelCreate.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/events/channelCreate.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | ||||||
|  | import Event from '../core/event'; | ||||||
|  | import { client } from '../index'; | ||||||
|  | import $ from '../core/lib'; | ||||||
|  | import * as discord from 'discord.js'; | ||||||
|  | 
 | ||||||
|  | export default new Event<'channelCreate'>({ | ||||||
|  |   async on(channel) { | ||||||
|  |     const botGuilds = client.guilds; | ||||||
|  |     if (channel instanceof discord.GuildChannel) { | ||||||
|  |       const createdGuild = await botGuilds.fetch(channel.guild.id); | ||||||
|  |       $.log( | ||||||
|  |         `Channel created in '${createdGuild.name}' called '#${channel.name}'`, | ||||||
|  |       ); | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  | }); | ||||||
							
								
								
									
										16
									
								
								src/events/channelDelete.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/events/channelDelete.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | ||||||
|  | import Event from '../core/event'; | ||||||
|  | import { client } from '../index'; | ||||||
|  | import $ from '../core/lib'; | ||||||
|  | import * as discord from 'discord.js'; | ||||||
|  | 
 | ||||||
|  | export default new Event<'channelDelete'>({ | ||||||
|  |   async on(channel) { | ||||||
|  |     const botGuilds = client.guilds; | ||||||
|  |     if (channel instanceof discord.GuildChannel) { | ||||||
|  |       const createdGuild = await botGuilds.fetch(channel.guild.id); | ||||||
|  |       $.log( | ||||||
|  |         `Channel deleted in '${createdGuild.name}' called '#${channel.name}'`, | ||||||
|  |       ); | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  | }); | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue