Merge branch 'master' into 'master'

Fix resolver & package.json

See merge request engineering/communityrelations!1

Closes #1
merge-requests/2/merge
Matthew 2020-04-15 00:01:42 -04:00
commit 6f76abfe7c
2 changed files with 21 additions and 8 deletions

View File

@ -2,10 +2,10 @@
"name": "loccommunityrelations", "name": "loccommunityrelations",
"version": "1.0.0", "version": "1.0.0",
"description": "The official system for handling Community Relations in the LOC Discord server.", "description": "The official system for handling Community Relations in the LOC Discord server.",
"main": "dist/client.js", "main": "build/main.js",
"repository": "https://gitlab.libraryofcode.org/engineering/communityrelations.git", "repository": "https://gitlab.libraryofcode.org/engineering/communityrelations.git",
"author": "Matthew R <matthew@staff.libraryofcode.org>", "author": "Matthew R <matthew@staff.libraryofcode.org>",
"license": "MIT", "license": "AGPL-3.0",
"private": false, "private": false,
"devDependencies": { "devDependencies": {
"@types/node": "^13.11.0", "@types/node": "^13.11.0",

View File

@ -49,13 +49,26 @@ export default class Util {
public resolveMember(message: Message, search: string, guild: Guild): Member | undefined { public resolveMember(message: Message, search: string, guild: Guild): Member | undefined {
try { try {
let mem = guild.members.find((member) => `${member.user.username}#${member.user.discriminator}` === search || member.user.username === search || member.id === search || (message.mentions[0] && member.id === message.mentions[0].id) || (member.nick !== undefined && member.nick === search)); let member = guild.members.find((mem) => `${mem.user.username}#${mem.user.discriminator}` === search || mem.user.id === search || mem.user.username === search || mem.user.username.startsWith(search) || mem.user.username.toLowerCase() === search.toLowerCase() || mem.user.username.toLowerCase().startsWith(search.toLowerCase()));
// Nickname
// eslint-disable-next-line no-mixed-operators // eslint-disable-next-line no-mixed-operators
if (!mem) mem = guild.members.find((member) => `${member.user.username.toLowerCase()}#${member.user.discriminator}` === search.toLowerCase() || member.user.username.toLowerCase() === search.toLowerCase() || member.nick !== undefined && member.nick.toLowerCase() === search.toLowerCase()); if (!member) {
member = guild.members.find((mem) => mem.nick && (mem.nick === search || mem.nick.startsWith(search) || mem.nick.toLowerCase() === search.toLowerCase() || mem.nick.toLowerCase().startsWith(search.toLowerCase())));
}
if (search.split(' ').length > 1 && !member) {
let nSearch = search.split(' ');
while (!member && nSearch.length > 0) {
nSearch = nSearch.slice(0, nSearch.length - 1);
member = guild.members.find((mem) => `${mem.user.username}#${mem.user.discriminator}` === search || mem.user.id === search || mem.user.username === search || mem.user.username.startsWith(search) || mem.user.username.toLowerCase() === search.toLowerCase() || mem.user.username.toLowerCase().startsWith(search.toLowerCase()));
// Nickname
// eslint-disable-next-line no-mixed-operators // eslint-disable-next-line no-mixed-operators
if (!mem) mem = guild.members.find((member) => member.user.username.toLowerCase().includes(search.toLowerCase()) || member.nick !== undefined && member.nick.toLowerCase().includes(search.toLowerCase())); if (!member) {
if (mem) return mem; member = guild.members.find((mem) => mem.nick && (mem.nick === search || mem.nick.startsWith(search) || mem.nick.toLowerCase() === search.toLowerCase() || mem.nick.toLowerCase().startsWith(search.toLowerCase())));
return undefined; }
}
}
if (!member) return undefined;
return member;
} catch { } catch {
return undefined; return undefined;
} }