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