fix for members command
parent
5b31d5f88c
commit
9762dd87cd
|
@ -1,6 +1,7 @@
|
|||
import { Message } from 'eris';
|
||||
import { createPaginationEmbed } from 'eris-pagination';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
import { members } from '.';
|
||||
|
||||
export default class extends Command {
|
||||
constructor(client: Client) {
|
||||
|
@ -9,7 +10,7 @@ export default class extends Command {
|
|||
this.description = 'Gets a list of members in the server or members in a specific role.';
|
||||
this.usage = `${this.client.config.prefix}members [role name]`;
|
||||
this.guildOnly = true;
|
||||
this.enabled = false;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
public async run(message: Message, args: string[]) {
|
||||
|
@ -20,19 +21,12 @@ export default class extends Command {
|
|||
const membersOnline = this.mainGuild.members.filter((member) => member.status === 'online');
|
||||
const membersIdle = this.mainGuild.members.filter((member) => member.status === 'idle');
|
||||
const membersDnd = this.mainGuild.members.filter((member) => member.status === 'dnd');
|
||||
const membersOffline = this.mainGuild.members.filter((member) => member.status === 'offline');
|
||||
const membersOffline = this.mainGuild.members.filter((member) => member.status === 'offline' || member.status === undefined);
|
||||
const membersBots = this.mainGuild.members.filter((member) => member.user.bot === true);
|
||||
const membersHuman = this.mainGuild.members.filter((member) => member.user.bot === false);
|
||||
|
||||
embed.setTitle('Members');
|
||||
embed.addField('Total', `${this.mainGuild.members.size}`, true);
|
||||
embed.addField('Humans', `${membersHuman.length}`, true);
|
||||
embed.addField('Bots', `${membersBots.length}`, true);
|
||||
embed.addBlankField();
|
||||
embed.addField('Online', `${membersOnline.length}`, true);
|
||||
embed.addField('Idle', `${membersIdle.length}`, true);
|
||||
embed.addField('Do Not Disturb', `${membersDnd.length}`, true);
|
||||
embed.addField('Offline', `${membersOffline.length}`, true);
|
||||
embed.setDescription(`**Total:** ${this.mainGuild.members.size}\n**Humans:** ${membersHuman.length}\n**Bots:** ${membersBots.length}\n\n**<:online:732025023547834369> Online:** ${membersOnline.length}\n**<:idle:732025087896715344> Idle:** ${membersIdle.length}\n**<:dnd:732024861853089933> Do Not Disturb:** ${membersDnd.length}\n**<:offline:732024920518688849> Offline:** ${membersOffline.length}`);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
|
||||
|
@ -41,7 +35,7 @@ export default class extends Command {
|
|||
|
||||
const role = this.client.util.resolveRole(args.join(' '), this.mainGuild);
|
||||
if (!role) return this.error(message.channel, 'The role you specified doesn\'t exist.');
|
||||
const membersArray: [{name: string, value: string}?] = [];
|
||||
const statusArray: string[] = [];
|
||||
const membersOnline: string[] = [];
|
||||
const membersIdle: string[] = [];
|
||||
const membersDnd: string[] = [];
|
||||
|
@ -49,38 +43,37 @@ export default class extends Command {
|
|||
for (const member of this.mainGuild.members.filter((m) => m.roles.includes(role.id)).sort((a, b) => a.username.localeCompare(b.username))) {
|
||||
switch (member.status) {
|
||||
case 'online':
|
||||
membersOnline.push(`${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
membersOnline.push(`<:online:732025023547834369> ${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
break;
|
||||
case 'idle':
|
||||
membersIdle.push(`${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
membersIdle.push(`<:idle:732025087896715344> ${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
break;
|
||||
case 'dnd':
|
||||
membersDnd.push(`${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
membersDnd.push(`<:dnd:732024861853089933> ${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
break;
|
||||
case 'offline':
|
||||
membersOffline.push(`${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
membersOffline.push(`<:offline:732024920518688849> ${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
break;
|
||||
case undefined:
|
||||
membersOffline.push(`${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
membersOffline.push(`<:offline:732024920518688849> ${member.user.username}#${member.user.discriminator} | <@${member.user.id}>`);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (membersOnline.length > 0) membersArray.push({ name: 'Online', value: membersOnline.join('\n') });
|
||||
if (membersIdle.length > 0) membersArray.push({ name: 'Idle', value: membersIdle.join('\n') });
|
||||
if (membersDnd.length > 0) membersArray.push({ name: 'Do Not Disturb', value: membersDnd.join('\n') });
|
||||
if (membersOffline.length > 0) membersArray.push({ name: 'Offline', value: membersOffline.join('\n') });
|
||||
const membersSplit = this.client.util.splitFields(membersArray);
|
||||
if (membersOnline.length > 0) statusArray.push(membersOnline.join('\n'));
|
||||
if (membersIdle.length > 0) statusArray.push(membersIdle.join('\n'));
|
||||
if (membersDnd.length > 0) statusArray.push(membersDnd.join('\n'));
|
||||
if (membersOffline.length > 0) statusArray.push(membersOffline.join('\n'));
|
||||
const statusSplit = this.client.util.splitString(statusArray.join('\n'), 2000);
|
||||
const cmdPages: RichEmbed[] = [];
|
||||
membersSplit.forEach((split) => {
|
||||
statusSplit.forEach((split) => {
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle(`Members in ${role.name}`);
|
||||
embed.setDescription(`Members in Role: ${membersOnline.length + membersIdle.length + membersDnd.length + membersOffline.length}`);
|
||||
embed.setDescription(`Members in Role: ${membersOnline.length + membersIdle.length + membersDnd.length + membersOffline.length}\n\n${split}`);
|
||||
embed.setColor(role.color);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
split.forEach((c) => embed.addField(c.name, c.value));
|
||||
return cmdPages.push(embed);
|
||||
});
|
||||
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
|
||||
|
|
Loading…
Reference in New Issue