From ba328b6c7d9449e94e1dc2e5ca60e24135dc600a Mon Sep 17 00:00:00 2001 From: Null Date: Tue, 14 Apr 2020 22:52:23 -0500 Subject: [PATCH 1/2] fix(src/class/Util.ts): Fix resolver --- src/class/Util.ts | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/class/Util.ts b/src/class/Util.ts index 798e0e4..23f59ed 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -49,13 +49,26 @@ export default class Util { public resolveMember(message: Message, search: string, guild: Guild): Member | undefined { 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 - 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()); - // 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 (mem) return mem; - return undefined; + 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 + 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 (!member) return undefined; + return member; } catch { return undefined; } From dd32619800688cdf569cae1bcc484b4e28d4235e Mon Sep 17 00:00:00 2001 From: Null Date: Tue, 14 Apr 2020 22:55:54 -0500 Subject: [PATCH 2/2] fix(package.json): Fix up package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 426d3fa..5210ec1 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "loccommunityrelations", "version": "1.0.0", "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", "author": "Matthew R ", - "license": "MIT", + "license": "AGPL-3.0", "private": false, "devDependencies": { "@types/node": "^13.11.0",