我有这个 memberlist 命令可以工作,但我遇到了问题。我没有收到任何错误,尽管它总是会发送 if(!members)
报价并且不会给我实际的成员列表。请帮忙谢谢
module.exports = {
name: 'memberlist',
description: 'shows the member list with the specified role',
async execute(message, args, Discord) {
const role = message.guild.roles.cache.get(args[0]);
const embe = new Discord.MessageEmbed()
.setDescription(`${message.author.username} Mention the role or put the role ID`)
.setColor("RANDOM")
.setTimestamp()
if(!role) return message.channel.send(embe);
const rid = message.content.split(' ').splice(1).join(' ');
const rrole = message.guild.roles.cache.find(val => val.id === rid);
if (!rrole) return message.channel.send({embed: {description: `${message.author.username}
\`${rid}\` is not a role on this server`, color: "RANDOM", timestamp: new Date()}});
const members = await message.guild.members.fetch().then((members) => {
if (Array.isArray(members)) {
return members(
(member) =>
`• **${members.displayName}**
(${members.username} - ${member.user.id})`
)
} else {
return `• **${members.displayName}**
(${members.username} - ${member.user.id})`
}
})
if(!members)
return message.channel.send({embed: {description:
`there are no members that currently have **${role.name}** role`, color: "RANDOM", timestamp: new Date()}});
const embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.addField({
name: `List of ${members}`,
value: `${members}
that have the role \`${role.name}\``,
description: members,
maxPerPage: 20,
page: Number(message.arg),
});
message.channel.send(embed)
}
}