Merge branch 'master' into 'master'
Fix resolver & package.json See merge request engineering/communityrelations!1 Closes #1merge-requests/2/merge
commit
6f76abfe7c
|
@ -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 <matthew@staff.libraryofcode.org>",
|
||||
"license": "MIT",
|
||||
"license": "AGPL-3.0",
|
||||
"private": false,
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.11.0",
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue