mirror of
				https://github.com/keanuplayz/TravBot-v3.git
				synced 2024-08-15 02:33:12 +00:00 
			
		
		
		
	Improved searching for users by name
This commit is contained in:
		
							parent
							
								
									564a419b40
								
							
						
					
					
						commit
						8094dbd6c8
					
				
					 8 changed files with 54 additions and 46 deletions
				
			
		|  | @ -3,6 +3,7 @@ | |||
| - Reworked `poll` | ||||
| - Extended stream notifications feature | ||||
| - Fixed various bugs | ||||
| - Improved searching for users by name | ||||
| 
 | ||||
| # 3.2.1 | ||||
| - `vaporwave`: Transforms input into full-width text | ||||
|  |  | |||
							
								
								
									
										18
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -1,12 +1,12 @@ | |||
| { | ||||
|     "name": "travebot", | ||||
|     "version": "3.2.1", | ||||
|     "version": "3.2.2", | ||||
|     "lockfileVersion": 2, | ||||
|     "requires": true, | ||||
|     "packages": { | ||||
|         "": { | ||||
|             "name": "travebot", | ||||
|             "version": "3.2.1", | ||||
|             "version": "3.2.2", | ||||
|             "hasInstallScript": true, | ||||
|             "license": "MIT", | ||||
|             "dependencies": { | ||||
|  | @ -20,7 +20,7 @@ | |||
|                 "mathjs": "^9.3.0", | ||||
|                 "moment": "^2.29.1", | ||||
|                 "ms": "^2.1.3", | ||||
|                 "onion-lasers": "^1.0.0", | ||||
|                 "onion-lasers": "^1.1.0", | ||||
|                 "relevant-urban": "^2.0.0", | ||||
|                 "translate-google": "^1.4.3", | ||||
|                 "weather-js": "^2.0.0" | ||||
|  | @ -5406,9 +5406,9 @@ | |||
|             } | ||||
|         }, | ||||
|         "node_modules/onion-lasers": { | ||||
|             "version": "1.0.0", | ||||
|             "resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.0.0.tgz", | ||||
|             "integrity": "sha512-vVpywipeVUBMffvhxTeq8i+kuIO3zV+t2RQcPFo7XiUjfARR6Kq4CGyPhi9EhVXmylzwSDH+HzBzxZcdfajqng==", | ||||
|             "version": "1.1.0", | ||||
|             "resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.1.0.tgz", | ||||
|             "integrity": "sha512-mwdRwvWTsDbiMkYGRskn05fqxvmJm+Mft10rjF5WwHZUm0wpSzD/nZrsrlkQ5KlCzDQJfKD5du8ZM0VX/35DQA==", | ||||
|             "dependencies": { | ||||
|                 "discord.js": "^12.5.3", | ||||
|                 "glob": "^7.1.6" | ||||
|  | @ -12425,9 +12425,9 @@ | |||
|             } | ||||
|         }, | ||||
|         "onion-lasers": { | ||||
|             "version": "1.0.0", | ||||
|             "resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.0.0.tgz", | ||||
|             "integrity": "sha512-vVpywipeVUBMffvhxTeq8i+kuIO3zV+t2RQcPFo7XiUjfARR6Kq4CGyPhi9EhVXmylzwSDH+HzBzxZcdfajqng==", | ||||
|             "version": "1.1.0", | ||||
|             "resolved": "https://registry.npmjs.org/onion-lasers/-/onion-lasers-1.1.0.tgz", | ||||
|             "integrity": "sha512-mwdRwvWTsDbiMkYGRskn05fqxvmJm+Mft10rjF5WwHZUm0wpSzD/nZrsrlkQ5KlCzDQJfKD5du8ZM0VX/35DQA==", | ||||
|             "requires": { | ||||
|                 "discord.js": "^12.5.3", | ||||
|                 "glob": "^7.1.6" | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| { | ||||
|     "name": "travebot", | ||||
|     "version": "3.2.1", | ||||
|     "version": "3.2.2", | ||||
|     "description": "TravBot Discord bot.", | ||||
|     "main": "dist/index.js", | ||||
|     "scripts": { | ||||
|  | @ -23,7 +23,7 @@ | |||
|         "mathjs": "^9.3.0", | ||||
|         "moment": "^2.29.1", | ||||
|         "ms": "^2.1.3", | ||||
|         "onion-lasers": "^1.0.0", | ||||
|         "onion-lasers": "^1.1.0", | ||||
|         "relevant-urban": "^2.0.0", | ||||
|         "translate-google": "^1.4.3", | ||||
|         "weather-js": "^2.0.0" | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {Command, NamedCommand, getMemberByName, RestCommand} from "onion-lasers"; | ||||
| import {Command, NamedCommand, getUserByNickname, RestCommand} from "onion-lasers"; | ||||
| import {isAuthorized, getMoneyEmbed} from "./modules/eco-utils"; | ||||
| import {DailyCommand, PayCommand, GuildCommand, LeaderboardCommand} from "./modules/eco-core"; | ||||
| import {BuyCommand, ShopCommand} from "./modules/eco-shop"; | ||||
|  | @ -36,9 +36,9 @@ export default new NamedCommand({ | |||
|         description: "See how much money someone else has by using their username.", | ||||
|         async run({send, guild, channel, combined}) { | ||||
|             if (isAuthorized(guild, channel)) { | ||||
|                 const member = await getMemberByName(guild!, combined); | ||||
|                 if (typeof member !== "string") send(getMoneyEmbed(member.user)); | ||||
|                 else send(member); | ||||
|                 const user = await getUserByNickname(combined, guild); | ||||
|                 if (typeof user !== "string") send(getMoneyEmbed(user)); | ||||
|                 else send(user); | ||||
|             } | ||||
|         } | ||||
|     }) | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import {Command, getMemberByName, NamedCommand, confirm, RestCommand} from "onion-lasers"; | ||||
| import {Command, getUserByNickname, NamedCommand, confirm, RestCommand} from "onion-lasers"; | ||||
| import {pluralise} from "../../../lib"; | ||||
| import {Storage} from "../../../structures"; | ||||
| import {isAuthorized, getMoneyEmbed, getSendEmbed, ECO_EMBED_COLOR} from "./eco-utils"; | ||||
|  | @ -156,20 +156,18 @@ export const PayCommand = new NamedCommand({ | |||
|                 else if (!guild) | ||||
|                     return send("You have to use this in a server if you want to send Mons with a username!"); | ||||
| 
 | ||||
|                 const member = await getMemberByName(guild, combined); | ||||
|                 if (typeof member === "string") return send(member); | ||||
|                 else if (member.user.id === author.id) return send("You can't send Mons to yourself!"); | ||||
|                 else if (member.user.bot && process.argv[2] !== "dev") return send("You can't send Mons to a bot!"); | ||||
|                 const user = await getUserByNickname(combined, guild); | ||||
|                 if (typeof user === "string") return send(user); | ||||
|                 else if (user.id === author.id) return send("You can't send Mons to yourself!"); | ||||
|                 else if (user.bot && !IS_DEV_MODE) return send("You can't send Mons to a bot!"); | ||||
| 
 | ||||
|                 const target = member.user; | ||||
| 
 | ||||
|                 const result = await confirm( | ||||
|                 const confirmed = await confirm( | ||||
|                     await send(`Are you sure you want to send ${pluralise(amount, "Mon", "s")} to this person?`, { | ||||
|                         embed: { | ||||
|                             color: ECO_EMBED_COLOR, | ||||
|                             author: { | ||||
|                                 name: target.tag, | ||||
|                                 icon_url: target.displayAvatarURL({ | ||||
|                                 name: user.tag, | ||||
|                                 icon_url: user.displayAvatarURL({ | ||||
|                                     format: "png", | ||||
|                                     dynamic: true | ||||
|                                 }) | ||||
|  | @ -179,12 +177,12 @@ export const PayCommand = new NamedCommand({ | |||
|                     author.id | ||||
|                 ); | ||||
| 
 | ||||
|                 if (result) { | ||||
|                     const receiver = Storage.getUser(target.id); | ||||
|                 if (confirmed) { | ||||
|                     const receiver = Storage.getUser(user.id); | ||||
|                     sender.money -= amount; | ||||
|                     receiver.money += amount; | ||||
|                     Storage.save(); | ||||
|                     send(getSendEmbed(author, target, amount)); | ||||
|                     send(getSendEmbed(author, user, amount)); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import {User} from "discord.js"; | ||||
| import {Command, NamedCommand, getMemberByName, CHANNEL_TYPE, RestCommand} from "onion-lasers"; | ||||
| import {Command, NamedCommand, getUserByNickname, RestCommand} from "onion-lasers"; | ||||
| 
 | ||||
| // Quotes must be used here or the numbers will change
 | ||||
| const registry: {[id: string]: string} = { | ||||
|  | @ -69,18 +69,17 @@ export default new NamedCommand({ | |||
|         } | ||||
|     }), | ||||
|     any: new RestCommand({ | ||||
|         channelType: CHANNEL_TYPE.GUILD, | ||||
|         async run({send, guild, combined}) { | ||||
|             const member = await getMemberByName(guild!, combined); | ||||
|             const user = await getUserByNickname(combined, guild); | ||||
| 
 | ||||
|             if (typeof member !== "string") { | ||||
|                 if (member.id in registry) { | ||||
|                     send(registry[member.id]); | ||||
|             if (typeof user !== "string") { | ||||
|                 if (user.id in registry) { | ||||
|                     send(registry[user.id]); | ||||
|                 } else { | ||||
|                     send(`\`${member.nickname ?? member.user.username}\` hasn't been added to the registry yet!`); | ||||
|                     send(`\`${user.tag}\` hasn't been added to the registry yet!`); | ||||
|                 } | ||||
|             } else { | ||||
|                 send(member); | ||||
|                 send(user); | ||||
|             } | ||||
|         } | ||||
|     }) | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import {MessageEmbed, version as djsversion, Guild, User, GuildMember} from "discord.js"; | ||||
| import ms from "ms"; | ||||
| import os from "os"; | ||||
| import {Command, NamedCommand, getMemberByName, CHANNEL_TYPE, getGuildByName, RestCommand} from "onion-lasers"; | ||||
| import {Command, NamedCommand, getUserByNickname, CHANNEL_TYPE, getGuildByName, RestCommand} from "onion-lasers"; | ||||
| import {formatBytes, trimArray} from "../../lib"; | ||||
| import {verificationLevels, filterLevels, regions} from "../../defs/info"; | ||||
| import moment, {utc} from "moment"; | ||||
|  | @ -34,17 +34,17 @@ export default new NamedCommand({ | |||
|                 description: "Shows another user's avatar by searching their name", | ||||
|                 channelType: CHANNEL_TYPE.GUILD, | ||||
|                 async run({send, guild, combined}) { | ||||
|                     const member = await getMemberByName(guild!, combined); | ||||
|                     const user = await getUserByNickname(combined, guild); | ||||
| 
 | ||||
|                     if (typeof member !== "string") { | ||||
|                     if (typeof user !== "string") { | ||||
|                         send( | ||||
|                             member.user.displayAvatarURL({ | ||||
|                             user.displayAvatarURL({ | ||||
|                                 dynamic: true, | ||||
|                                 size: 2048 | ||||
|                             }) | ||||
|                         ); | ||||
|                     } else { | ||||
|                         send(member); | ||||
|                         send(user); | ||||
|                     } | ||||
|                 } | ||||
|             }) | ||||
|  | @ -125,9 +125,19 @@ export default new NamedCommand({ | |||
|         async run({send, guild, args}) { | ||||
|             const user = args[0] as User; | ||||
|             // Transforms the User object into a GuildMember object of the current guild.
 | ||||
|             const member = guild?.members.resolve(args[0]); | ||||
|             const member = guild?.members.resolve(user); | ||||
|             send(await getUserInfo(user, member)); | ||||
|         } | ||||
|     }), | ||||
|     any: new RestCommand({ | ||||
|         description: "Displays info about a user by their nickname or username.", | ||||
|         async run({send, guild, combined}) { | ||||
|             const user = await getUserByNickname(combined, guild); | ||||
|             // Transforms the User object into a GuildMember object of the current guild.
 | ||||
|             const member = guild?.members.resolve(user); | ||||
|             if (typeof user !== "string") send(await getUserInfo(user, member)); | ||||
|             else send(user); | ||||
|         } | ||||
|     }) | ||||
| }); | ||||
| 
 | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { | |||
|     askForReply, | ||||
|     confirm, | ||||
|     askMultipleChoice, | ||||
|     getMemberByName, | ||||
|     getUserByNickname, | ||||
|     RestCommand | ||||
| } from "onion-lasers"; | ||||
| import {Storage} from "../../structures"; | ||||
|  | @ -393,9 +393,9 @@ export default new NamedCommand({ | |||
|     any: new RestCommand({ | ||||
|         description: "See what time it is for someone else (by their username).", | ||||
|         async run({send, guild, combined}) { | ||||
|             const member = await getMemberByName(guild!, combined); | ||||
|             if (typeof member !== "string") send(getTimeEmbed(member.user)); | ||||
|             else send(member); | ||||
|             const user = await getUserByNickname(combined, guild); | ||||
|             if (typeof user !== "string") send(getTimeEmbed(user)); | ||||
|             else send(user); | ||||
|         } | ||||
|     }) | ||||
| }); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue