small fixes

This commit is contained in:
Erik 2020-08-14 01:12:48 +03:00
parent ca2ee0a5d8
commit 421dddfb03

View File

@ -41,9 +41,9 @@ class UserCommand extends Command {
let count = 0;
const keyFilterMember = (m) => m.nickname && (m.nickname.toLowerCase().includes(key) || similarity(m.nickname.toLowerCase(), key) > 0.75 && Math.abs(m.nickname.length - key.length) < 3) ||
m.user.username.toLowerCase().includes(key) || similarity(m.user.username.toLowerCase(), key) > 0.75 && Math.abs(m.user.username.length - key.length) < 3
m.user.username.toLowerCase().includes(key) || similarity(m.user.username.toLowerCase(), key) > 0.75 && Math.abs(m.user.username.length - key.length) < 3;
const discrimFilterMember = (m) => m.user.discriminator === key;
const keyFilterUser = (u) => u.username.toLowerCase().includes(key) || similarity(u.username, key) > 0.75 && Math.abs(u.username.length - key.length) < 3
const keyFilterUser = (u) => u.username.toLowerCase().includes(key) || similarity(u.username, key) > 0.75 && Math.abs(u.username.length - key.length) < 3;
const discrimFilterUser = (u) => u.discriminator === key;
const members = message.guild.members.cache.filter(args.discriminator ? discrimFilterMember : keyFilterMember);
@ -53,13 +53,13 @@ class UserCommand extends Command {
if (!users.size && !members.size) return message.formattedRespond('C_USER_SEARCH_404');
for(const [ id, member ] of members) {
response += `${member.user.tag} ${member.nickname ? `- ${member.nickname}` : ''} [${id}] <:members:741721081261588589>\n`;
response += `${Util.escapeMarkdown(member.user.tag)} ${member.nickname ? `- ${Util.escapeMarkdown(member.nickname)}` : ''} [${id}] <:members:741721081261588589>\n`;
count++;
if(response.length > 1900) break;
}
if (response.length < 1900) for (const [id, user] of users) {
response += `${user.tag} [${id}]\n`;
response += `${Util.escapeMarkdown(user.tag)} [${id}]\n`;
count++;
if (response.length > 1900) break;
}
@ -72,7 +72,7 @@ class UserCommand extends Command {
color: 0x0088cc,
footer: {
text: message.format('C_USER_SEARCH_FOOTER', {
matches: members.size,
matches: members.size + users.size,
count
})
}
@ -86,7 +86,7 @@ class UserCommand extends Command {
if (!user) return message.formattedRespond('C_USER_404');
} else user = message.author;
const member = await message.guild.members.fetch(user.id).catch(() => { });
const member = await message.guild.members.fetch(user.id).catch();
const { activities } = user.presence;
response = {
@ -102,6 +102,7 @@ class UserCommand extends Command {
id: user.id,
created: user.createdAt.toDateString(),
status: user.presence.status,
// eslint-disable-next-line no-nested-ternary
activity: activities.length > 0 ? activities[0].type === 'CUSTOM_STATUS' ? `${activities[0].name}: ${activities[0].state || 'emoji'}` : activities[0].name : 'Nothing',
globalActivity: user.lastMessage ? user.lastMessage.createdAt.toDateString() : 'N/A'
}),