mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Invert the purpose of the - argument.
				
					
				
			Also, increase the extensibility of the formatter by using CCBot's formatting system.
This commit is contained in:
		
							parent
							
								
									fb2335dda5
								
							
						
					
					
						commit
						7f719912b2
					
				
					 2 changed files with 32 additions and 15 deletions
				
			
		|  | @ -9,7 +9,7 @@ export default new NamedCommand({ | ||||||
|         description: "The emote(s) to send.", |         description: "The emote(s) to send.", | ||||||
|         usage: "<emotes...>", |         usage: "<emotes...>", | ||||||
|         async run({send, args}) { |         async run({send, args}) { | ||||||
|             const output = processEmoteQuery(args, true).join(""); |             const output = processEmoteQuery(args, true); | ||||||
|             if (output.length > 0) send(output); |             if (output.length > 0) send(output); | ||||||
|         } |         } | ||||||
|     }) |     }) | ||||||
|  |  | ||||||
|  | @ -93,20 +93,37 @@ export function searchNearestEmote(query: string, additionalEmotes?: GuildEmoji[ | ||||||
|     return "❓"; |     return "❓"; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function processEmoteQuery(query: string[], isFormatted: boolean): string[] { | // This formatting system was blatantly ripped from CCBot.
 | ||||||
|     return query.map((emote) => { | // <https://github.com/CCDirectLink/ccbot/blob/5b8aa0dbff012a35dc9a54e10b93a397edf6403d/src/commands/emotes.ts#L117-L141>
 | ||||||
|         emote = emote.trim(); | export function processEmoteQuery(query: string[], isFormatted: boolean): string { | ||||||
| 
 |     let text = ""; | ||||||
|         // If the query directly matches a Unicode emoji or a Discord custom emote mention, pass it as-is.
 |     let separator = ""; | ||||||
|         if (discordEmoteMentionRegex.test(emote) || unicodeEmojiRegex.test(emote)) return emote; |     for (let i = 0; i < query.length; i++) { | ||||||
| 
 |         const emoteArg: string = query[i]; | ||||||
|         // If formatted mode is enabled, parse whitespace and newline elements.
 |  | ||||||
|         if (isFormatted) { |         if (isFormatted) { | ||||||
|             if (emote == "-") return " "; |             switch (emoteArg) { | ||||||
|             if (emote == "+") return "\n"; |                 case "-": { | ||||||
|             if (emote == "_") return "\u200b"; |                     separator = ""; | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |                 case "+": { | ||||||
|  |                     separator = "\n"; | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |                 case "_": { | ||||||
|  |                     separator = "\u200b"; | ||||||
|  |                     break; | ||||||
|  |                 } | ||||||
|  |                 default: { | ||||||
|  |                     const emote = searchNearestEmote(emoteArg); | ||||||
|  |                     if (text.length > 0) text += separator; | ||||||
|  |                     text += emote.toString(); | ||||||
|  |                     separator = " "; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } else { | ||||||
|  |             text = searchNearestEmote(emoteArg); | ||||||
|         } |         } | ||||||
| 
 |     } | ||||||
|         return searchNearestEmote(emote); |     return text; | ||||||
|     }); |  | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue