mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Completed lsemotes. Various other changes.
- Replaced deprecated `version` input with `dockerx-version` - Replaced deprecated `equals` function with `strictEquals` - Fixed indentation on paginate function.
This commit is contained in:
		
							parent
							
								
									57a4c9f523
								
							
						
					
					
						commit
						57433cc594
					
				
					 4 changed files with 50 additions and 43 deletions
				
			
		
							
								
								
									
										2
									
								
								.github/workflows/image.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/image.yml
									
										
									
									
										vendored
									
									
								
							|  | @ -15,7 +15,7 @@ jobs: | ||||||
|         id: buildx |         id: buildx | ||||||
|         uses: crazy-max/ghaction-docker-buildx@v1 |         uses: crazy-max/ghaction-docker-buildx@v1 | ||||||
|         with: |         with: | ||||||
|           version: latest |           buildx-version: latest | ||||||
|       - name: Login to Docker Hub |       - name: Login to Docker Hub | ||||||
|         run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin |         run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||||||
|       - name: Build the image |       - name: Build the image | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ import Command from '../core/command'; | ||||||
| import {CommonLibrary} from '../core/lib'; | import {CommonLibrary} from '../core/lib'; | ||||||
| 
 | 
 | ||||||
| export default new Command({ | export default new Command({ | ||||||
| 	description: "", | 	description: "Various utilities.", | ||||||
| 	endpoint: false, | 	endpoint: false, | ||||||
| 	usage: '', | 	usage: '', | ||||||
| 	async run($: CommonLibrary): Promise<any> { | 	async run($: CommonLibrary): Promise<any> { | ||||||
|  | @ -16,14 +16,24 @@ export default new Command({ | ||||||
| 			async run($: CommonLibrary): Promise<any> { | 			async run($: CommonLibrary): Promise<any> { | ||||||
| 				const nsfw: string | string[] = []; | 				const nsfw: string | string[] = []; | ||||||
| 				const pages = $.client.emojis.cache.filter(x => !nsfw.includes(x.guild.id), this).array(); | 				const pages = $.client.emojis.cache.filter(x => !nsfw.includes(x.guild.id), this).array(); | ||||||
| 				// $.log(pages);
 | 				const pagesSplit = $(pages).split(20); | ||||||
|  | 				$.log(pagesSplit) | ||||||
| 				var embed = new MessageEmbed() | 				var embed = new MessageEmbed() | ||||||
| 					.setTitle("**Emoji list!**") | 					.setTitle("**Emoji list!**") | ||||||
| 					.setColor("AQUA"); | 					.setColor("AQUA") | ||||||
|  | 				let desc = "" | ||||||
|  | 				for (const emote of pagesSplit[0]) { | ||||||
|  | 					desc += `${emote} | ${emote.name}\n` | ||||||
|  | 				} | ||||||
|  | 				embed.setDescription(desc) | ||||||
| 				const msg = await $.channel.send({embed}); | 				const msg = await $.channel.send({embed}); | ||||||
| 
 | 
 | ||||||
| 				$.paginate(msg, $.author.id, pages.length, page => { | 				$.paginate(msg, $.author.id, pages.length, page => { | ||||||
| 					embed.setDescription(`${pages[page]} | ${pages[page].name}`); | 					let desc = "" | ||||||
|  | 					for(const emote of pagesSplit[page]) { | ||||||
|  | 						desc += `${emote} | ${emote.name}\n` | ||||||
|  | 					} | ||||||
|  | 					embed.setDescription(desc) | ||||||
| 					msg.edit(embed); | 					msg.edit(embed); | ||||||
| 				}); | 				}); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | @ -171,13 +171,13 @@ $.paginate = async(message: Message, senderID: string, total: number, callback: | ||||||
|         	case '⬅️': turn(-1); break; |         	case '⬅️': turn(-1); break; | ||||||
|         	case '➡️': turn(1); break; |         	case '➡️': turn(1); break; | ||||||
|     	} |     	} | ||||||
| }; | 	}; | ||||||
| 
 | 
 | ||||||
| // Listen for reactions and call the handler.
 | 	// Listen for reactions and call the handler.
 | ||||||
| await message.react('⬅️'); | 	await message.react('⬅️'); | ||||||
| await message.react('➡️'); | 	await message.react('➡️'); | ||||||
| eventListeners.set(message.id, handle); | 	eventListeners.set(message.id, handle); | ||||||
| await message.awaitReactions((reaction, user) => { | 	await message.awaitReactions((reaction, user) => { | ||||||
|     	if(user.id === senderID) |     	if(user.id === senderID) | ||||||
|     	{ |     	{ | ||||||
|         	// The reason this is inside the call is because it's possible to switch a user's permissions halfway and suddenly throw an error.
 |         	// The reason this is inside the call is because it's possible to switch a user's permissions halfway and suddenly throw an error.
 | ||||||
|  | @ -188,12 +188,8 @@ await message.awaitReactions((reaction, user) => { | ||||||
|         	if(canDeleteEmotes) |         	if(canDeleteEmotes) | ||||||
|             	reaction.users.remove(user); |             	reaction.users.remove(user); | ||||||
|     	} |     	} | ||||||
|      |  | ||||||
|     	return false; |     	return false; | ||||||
| }, {time: duration}); | 	}, {time: duration}); | ||||||
| 
 |  | ||||||
| 	$.log("removal") |  | ||||||
| 	 |  | ||||||
| 	// When time's up, remove the bot's own reactions.
 | 	// When time's up, remove the bot's own reactions.
 | ||||||
| 	eventListeners.delete(message.id); | 	eventListeners.delete(message.id); | ||||||
| 	message.reactions.cache.get('⬅️')?.users.remove(message.author); | 	message.reactions.cache.get('⬅️')?.users.remove(message.author); | ||||||
|  | @ -387,6 +383,7 @@ export abstract class GenericStructure | ||||||
| 	public save(asynchronous = true) | 	public save(asynchronous = true) | ||||||
| 	{ | 	{ | ||||||
| 		const tag = this.__meta__; | 		const tag = this.__meta__; | ||||||
|  | 		/// @ts-ignore
 | ||||||
| 		delete this.__meta__; | 		delete this.__meta__; | ||||||
| 		FileManager.write(tag, this, asynchronous); | 		FileManager.write(tag, this, asynchronous); | ||||||
| 		this.__meta__ = tag; | 		this.__meta__ = tag; | ||||||
|  |  | ||||||
|  | @ -6,41 +6,41 @@ describe("Wrappers", () => { | ||||||
| 	describe("NumberWrapper", () => { | 	describe("NumberWrapper", () => { | ||||||
| 		describe("#pluralise()", () => { | 		describe("#pluralise()", () => { | ||||||
| 			it('should return "5 credits"', () => { | 			it('should return "5 credits"', () => { | ||||||
| 				assert.equal(new NumberWrapper(5).pluralise("credit", "s"), "5 credits"); | 				assert.strictEqual(new NumberWrapper(5).pluralise("credit", "s"), "5 credits"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should return "1 credit"', () => { | 			it('should return "1 credit"', () => { | ||||||
| 				assert.equal(new NumberWrapper(1).pluralise("credit", "s"), "1 credit"); | 				assert.strictEqual(new NumberWrapper(1).pluralise("credit", "s"), "1 credit"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should return "-1 credits"', () => { | 			it('should return "-1 credits"', () => { | ||||||
| 				assert.equal(new NumberWrapper(-1).pluralise("credit", "s"), "-1 credits"); | 				assert.strictEqual(new NumberWrapper(-1).pluralise("credit", "s"), "-1 credits"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should be able to work with a plural suffix', () => { | 			it('should be able to work with a plural suffix', () => { | ||||||
| 				assert.equal(new NumberWrapper(2).pluralise("part", "ies", "y"), "2 parties"); | 				assert.strictEqual(new NumberWrapper(2).pluralise("part", "ies", "y"), "2 parties"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should be able to work with a singular suffix', () => { | 			it('should be able to work with a singular suffix', () => { | ||||||
| 				assert.equal(new NumberWrapper(1).pluralise("part", "ies", "y"), "1 party"); | 				assert.strictEqual(new NumberWrapper(1).pluralise("part", "ies", "y"), "1 party"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should be able to exclude the number', () => { | 			it('should be able to exclude the number', () => { | ||||||
| 				assert.equal(new NumberWrapper(1).pluralise("credit", "s", "", true), "credit"); | 				assert.strictEqual(new NumberWrapper(1).pluralise("credit", "s", "", true), "credit"); | ||||||
| 			}) | 			}) | ||||||
| 		}) | 		}) | ||||||
| 		 | 		 | ||||||
| 		describe("#pluraliseSigned()", () => { | 		describe("#pluraliseSigned()", () => { | ||||||
| 			it('should return "-1 credits"', () => { | 			it('should return "-1 credits"', () => { | ||||||
| 				assert.equal(new NumberWrapper(-1).pluraliseSigned("credit", "s"), "-1 credits"); | 				assert.strictEqual(new NumberWrapper(-1).pluraliseSigned("credit", "s"), "-1 credits"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should return "+0 credits"', () => { | 			it('should return "+0 credits"', () => { | ||||||
| 				assert.equal(new NumberWrapper(0).pluraliseSigned("credit", "s"), "+0 credits"); | 				assert.strictEqual(new NumberWrapper(0).pluraliseSigned("credit", "s"), "+0 credits"); | ||||||
| 			}) | 			}) | ||||||
| 			 | 			 | ||||||
| 			it('should return "+1 credit"', () => { | 			it('should return "+1 credit"', () => { | ||||||
| 				assert.equal(new NumberWrapper(1).pluraliseSigned("credit", "s"), "+1 credit"); | 				assert.strictEqual(new NumberWrapper(1).pluraliseSigned("credit", "s"), "+1 credit"); | ||||||
| 			}) | 			}) | ||||||
| 		}) | 		}) | ||||||
| 	}) | 	}) | ||||||
|  | @ -48,13 +48,13 @@ describe("Wrappers", () => { | ||||||
| 	describe("StringWrapper", () => { | 	describe("StringWrapper", () => { | ||||||
| 		describe("#replaceAll()", () => { | 		describe("#replaceAll()", () => { | ||||||
| 			it('should convert "test" to "zesz"', () => { | 			it('should convert "test" to "zesz"', () => { | ||||||
| 				assert.equal(new StringWrapper("test").replaceAll('t', 'z'), "zesz"); | 				assert.strictEqual(new StringWrapper("test").replaceAll('t', 'z'), "zesz"); | ||||||
| 			}) | 			}) | ||||||
| 		}) | 		}) | ||||||
| 		 | 		 | ||||||
| 		describe("#toTitleCase()", () => { | 		describe("#toTitleCase()", () => { | ||||||
| 			it('should capitalize the first letter of each word', () => { | 			it('should capitalize the first letter of each word', () => { | ||||||
| 				assert.equal(new StringWrapper("yeetus deletus find salvation from jesus").toTitleCase(), "Yeetus Deletus Find Salvation From Jesus"); | 				assert.strictEqual(new StringWrapper("yeetus deletus find salvation from jesus").toTitleCase(), "Yeetus Deletus Find Salvation From Jesus"); | ||||||
| 			}) | 			}) | ||||||
| 		}) | 		}) | ||||||
| 	}) | 	}) | ||||||
|  | @ -62,7 +62,7 @@ describe("Wrappers", () => { | ||||||
| 	describe("ArrayWrapper", () => { | 	describe("ArrayWrapper", () => { | ||||||
| 		describe("#split()", () => { | 		describe("#split()", () => { | ||||||
| 			it('should split [1,2,3,4,5,6,7,8,9,10] into [[1,2,3],[4,5,6],[7,8,9],[10]]', () => { | 			it('should split [1,2,3,4,5,6,7,8,9,10] into [[1,2,3],[4,5,6],[7,8,9],[10]]', () => { | ||||||
| 				assert.deepEqual(new ArrayWrapper([1,2,3,4,5,6,7,8,9,10]).split(3), [[1,2,3],[4,5,6],[7,8,9],[10]]); | 				assert.deepStrictEqual(new ArrayWrapper([1,2,3,4,5,6,7,8,9,10]).split(3), [[1,2,3],[4,5,6],[7,8,9],[10]]); | ||||||
| 			}) | 			}) | ||||||
| 		}) | 		}) | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue